Class: CSVPlusPlus::Entities::Boolean
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/entities/boolean.rb
Overview
A boolean value
Instance Attribute Summary collapse
-
#value ⇒ true, false
readonly
The current value of value.
Instance Method Summary collapse
- #==(other) ⇒ ::T::Boolean
- #evaluate(_position) ⇒ ::String
-
#initialize(value) ⇒ Boolean
constructor
A new instance of Boolean.
Constructor Details
#initialize(value) ⇒ Boolean
Returns a new instance of Boolean.
17 18 19 20 21 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 17 def initialize(value) super() # TODO: probably can do a lot better in general on type validation @value = ::T.let(value.is_a?(::String) ? (value.downcase == 'true') : value, ::T::Boolean) end |
Instance Attribute Details
#value ⇒ true, false (readonly)
Returns the current value of value.
9 10 11 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 9 def value @value end |
Instance Method Details
#==(other) ⇒ ::T::Boolean
37 38 39 40 41 42 43 44 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 37 def ==(other) case other when self.class value == other.value else false end end |
#evaluate(_position) ⇒ ::String
29 30 31 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 29 def evaluate(_position) @value.to_s.upcase end |