Class: CSVPlusPlus::Entities::Number
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/entities/number.rb
Overview
A number value
Instance Attribute Summary collapse
-
#value ⇒ Numeric
readonly
The parsed number value.
Instance Method Summary collapse
- #==(other) ⇒ ::T::Boolean
- #evaluate(_position) ⇒ ::String
-
#initialize(value) ⇒ Number
constructor
A new instance of Number.
Constructor Details
#initialize(value) ⇒ Number
Returns a new instance of Number.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/csv_plus_plus/entities/number.rb', line 17 def initialize(value) super() @value = ::T.let( (if value.is_a?(::String) value.include?('.') ? Float(value) : Integer(value, 10) else value end), ::Numeric ) end |
Instance Attribute Details
#value ⇒ Numeric (readonly)
The parsed number value
9 10 11 |
# File 'lib/csv_plus_plus/entities/number.rb', line 9 def value @value end |
Instance Method Details
#==(other) ⇒ ::T::Boolean
43 44 45 46 47 48 49 50 |
# File 'lib/csv_plus_plus/entities/number.rb', line 43 def ==(other) case other when self.class @value == other.value else false end end |
#evaluate(_position) ⇒ ::String
35 36 37 |
# File 'lib/csv_plus_plus/entities/number.rb', line 35 def evaluate(_position) @value.to_s end |