Class: CSVPlusPlus::Language::Entities::Boolean

Inherits:
Entity
  • Object
show all
Defined in:
lib/csv_plus_plus/language/entities/boolean.rb

Overview

A boolean value

Instance Attribute Summary collapse

Attributes inherited from Entity

#id, #type

Instance Method Summary collapse

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

#valueObject (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_sObject

to_s



21
22
23
# File 'lib/csv_plus_plus/language/entities/boolean.rb', line 21

def to_s
  @value.to_s.upcase
end