Class: EacRubyUtils::Boolean

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/boolean.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Boolean

Returns a new instance of Boolean.



27
28
29
# File 'lib/eac_ruby_utils/boolean.rb', line 27

def initialize(value)
  @value = self.class.parse(value)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



25
26
27
# File 'lib/eac_ruby_utils/boolean.rb', line 25

def value
  @value
end

Class Method Details

.parse(value) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/eac_ruby_utils/boolean.rb', line 6

def parse(value)
  return parse_string(value) if value.is_a?(::String)
  return parse_string(value.to_s) if value.is_a?(::Symbol)
  return parse_number(value) if value.is_a?(::Number)

  value ? true : false
end