-
Notifications
You must be signed in to change notification settings - Fork 0
Data Types
Paul Götze edited this page Sep 22, 2015
·
1 revision
Data Types are parsed as their class constant (with some exceptions):
CodeBreaker.parse("true")
# => TrueClass
CodeBreaker.parse("false")
# => FalseClass
CodeBreaker.parse("'some string'")
# => String
CodeBreaker.parse("1")
# => Fixnum
CodeBreaker.parse("1_000_000_000_000_000_000_000_000_000")
# => Bignum
CodeBreaker.parse("Rational(2, 3)")
# => Rational
CodeBreaker.parse("Complex(2.3, 4.1)")
# => Complex
CodeBreaker.parse(":title")
# => Symbol
CodeBreaker.parse("1.3")
# => Float
CodeBreaker.parse("/a/")
# => Regexp
CodeBreaker.parse("{firstname: 'Joe', lastname: 'Dohn'}")
# => {:hash=>[{Symbol=>String}, {Symbol=>String}]}
CodeBreaker.parse("[1, 2, 3, '4']")
# => {:array=>[Fixnum, Fixnum, Fixnum, String]}
CodeBreaker.parse('%x[ruby -v]')
# => {:xstr=>String}