Class: Elparser::SExpNumber
Class Method Summary
collapse
Instance Method Summary
collapse
#atom?
#==, #atom?, #cons?, #list?, #visit
Constructor Details
#initialize(type, val) ⇒ SExpNumber
Returns a new instance of SExpNumber.
91
92
93
94
|
# File 'lib/elparser.rb', line 91
def initialize(type, val)
@type = type
@val = val
end
|
Class Method Details
.float(val) ⇒ Object
87
88
89
|
# File 'lib/elparser.rb', line 87
def self.float(val)
SExpNumber.new(:FLOAT, val)
end
|
.int(val) ⇒ Object
84
85
86
|
# File 'lib/elparser.rb', line 84
def self.int(val)
SExpNumber.new(:INTEGER, val)
end
|
Instance Method Details
#to_ruby ⇒ Object
108
109
110
|
# File 'lib/elparser.rb', line 108
def to_ruby
value
end
|
#to_s ⇒ Object
105
106
107
|
# File 'lib/elparser.rb', line 105
def to_s
@val
end
|
#value ⇒ Object
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/elparser.rb', line 95
def value
case @type
when :INTEGER
@val.to_i
when :FLOAT
@val.to_f
else
raise "Unknown type #{@type}:#{@val}"
end
end
|