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) ⇒ boolean
-
#initialize(value) ⇒ Boolean
constructor
A new instance of Boolean.
- #to_s ⇒ String
Methods inherited from Entity
#method_missing, #respond_to_missing?
Constructor Details
#initialize(value) ⇒ Boolean
Returns a new instance of Boolean.
14 15 16 17 18 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 14 def initialize(value) super(:boolean) # TODO: probably can do a lot better in general on type validation @value = value.is_a?(::String) ? (value.downcase == 'true') : value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CSVPlusPlus::Entities::Entity
Instance Attribute Details
#value ⇒ true, false (readonly)
Returns the current value of value.
10 11 12 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 10 def value @value end |
Instance Method Details
#==(other) ⇒ boolean
26 27 28 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 26 def ==(other) super && value == other.value end |
#to_s ⇒ String
21 22 23 |
# File 'lib/csv_plus_plus/entities/boolean.rb', line 21 def to_s @value.to_s.upcase end |