Class: CSVPlusPlus::Language::Entities::Number
- Defined in:
- lib/csv_plus_plus/language/entities/number.rb
Overview
A number value
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Entity
Instance Method Summary collapse
-
#==(other) ⇒ Object
.
-
#initialize(value) ⇒ Number
constructor
initialize.
-
#to_s ⇒ Object
to_s.
Methods inherited from Entity
#method_missing, #respond_to_missing?
Constructor Details
#initialize(value) ⇒ Number
initialize
12 13 14 15 16 17 18 19 20 |
# File 'lib/csv_plus_plus/language/entities/number.rb', line 12 def initialize(value) super(:number) @value = if value.instance_of?(::String) value.include?('.') ? Float(value) : Integer(value, 10) else value end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CSVPlusPlus::Language::Entities::Entity
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/csv_plus_plus/language/entities/number.rb', line 9 def value @value end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/csv_plus_plus/language/entities/number.rb', line 28 def ==(other) super && value == other.value end |
#to_s ⇒ Object
to_s
23 24 25 |
# File 'lib/csv_plus_plus/language/entities/number.rb', line 23 def to_s @value.to_s end |