Class: MuchBoolean
- Inherits:
-
Object
- Object
- MuchBoolean
- Defined in:
- lib/much-boolean.rb,
lib/much-boolean/version.rb
Constant Summary collapse
- FALSE_VALUES =
[ nil, 0, '0', false, 'false', 'False', 'FALSE', 'f', 'F', 'no', 'No', 'NO', 'n', 'N' ].freeze
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#given ⇒ Object
readonly
Returns the value of attribute given.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other_boolean) ⇒ Object
-
#initialize(given = nil) ⇒ MuchBoolean
constructor
A new instance of MuchBoolean.
Constructor Details
#initialize(given = nil) ⇒ MuchBoolean
Returns a new instance of MuchBoolean.
18 19 20 21 |
# File 'lib/much-boolean.rb', line 18 def initialize(given = nil) @given = given @actual = self.class.convert(@given) end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
16 17 18 |
# File 'lib/much-boolean.rb', line 16 def actual @actual end |
#given ⇒ Object (readonly)
Returns the value of attribute given.
16 17 18 |
# File 'lib/much-boolean.rb', line 16 def given @given end |
Class Method Details
.convert(value) ⇒ Object
12 13 14 |
# File 'lib/much-boolean.rb', line 12 def self.convert(value) !FALSE_VALUES.include?(value) end |
Instance Method Details
#==(other_boolean) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/much-boolean.rb', line 23 def ==(other_boolean) if other_boolean.kind_of?(MuchBoolean) self.actual == other_boolean.actual else self.actual == other_boolean end end |