Class: CSVPlusPlus::Entities::Boolean
- 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.
Attributes inherited from Entity
Instance Method Summary collapse
- #==(other) ⇒ ::T::Boolean
- #evaluate(_runtime) ⇒ ::String
-
#initialize(value) ⇒ Boolean
constructor
A new instance of Boolean.
Constructor Details
#initialize(value) ⇒ Boolean
Returns a new instance of Boolean.
15 16 17 18 19 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 15 def initialize(value) super(::CSVPlusPlus::Entities::Type::Boolean) # 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
33 34 35 36 37 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 33 def ==(other) return false unless super other.is_a?(self.class) && value == other.value end |
#evaluate(_runtime) ⇒ ::String
25 26 27 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 25 def evaluate(_runtime) @value.to_s.upcase end |