Class: CSVPlusPlus::Entities::Boolean

Inherits:
Entity
  • Object
show all
Defined in:
lib/csv_plus_plus/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

Returns a new instance of Boolean.

Parameters:



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

#valuetrue, false (readonly)

Returns the current value of value.

Returns:

  • (true, false)

    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

Returns:

  • (boolean)


26
27
28
# File 'lib/csv_plus_plus/entities/boolean.rb', line 26

def ==(other)
  super && value == other.value
end

#to_sString

Returns:



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

def to_s
  @value.to_s.upcase
end