Class: Lumb::Value
- Inherits:
-
Object
- Object
- Lumb::Value
- Defined in:
- lib/lumb/value.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(type, raw) ⇒ Value
constructor
A new instance of Value.
Constructor Details
#initialize(type, raw) ⇒ Value
Returns a new instance of Value.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lumb/value.rb', line 7 def initialize(type, raw) @type = type @value = nil @raw = raw case @type when :Num @value = @raw.to_i when :Sym @value = @raw.to_s[1..-1].to_sym when :Date @value = Date.parse(@raw) end end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/lumb/value.rb', line 5 def raw @raw end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/lumb/value.rb', line 5 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/lumb/value.rb', line 5 def value @value end |