Class: Lumb::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/lumb/value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/lumb/value.rb', line 5

def raw
  @raw
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/lumb/value.rb', line 5

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/lumb/value.rb', line 5

def value
  @value
end