Class: CSVPlusPlus::Language::Entities::Boolean
- Defined in:
- lib/csv_plus_plus/language/entities/boolean.rb
Overview
A boolean 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) ⇒ Boolean
constructor
initialize.
-
#to_s ⇒ Object
to_s.
Methods inherited from Entity
#method_missing, #respond_to_missing?
Constructor Details
#initialize(value) ⇒ Boolean
initialize
14 15 16 17 18 |
# File 'lib/csv_plus_plus/language/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::Language::Entities::Entity
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/csv_plus_plus/language/entities/boolean.rb', line 11 def value @value end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 |
# File 'lib/csv_plus_plus/language/entities/boolean.rb', line 26 def ==(other) super && value == other.value end |
#to_s ⇒ Object
to_s
21 22 23 |
# File 'lib/csv_plus_plus/language/entities/boolean.rb', line 21 def to_s @value.to_s.upcase end |