Class: MuchBoolean
- Inherits:
-
Object
- Object
- MuchBoolean
- Defined in:
- lib/much-boolean.rb,
lib/much-boolean/version.rb
Defined Under Namespace
Modules: Mapping
Constant Summary collapse
- FALSE_VALUES =
[ nil, "", :"", 0, "0", :"0", false, "f", :f, "F", :F, "false", :false, "False", :False, "FALSE", :FALSE, "off", :off, "Off", :Off, "OFF", :OFF, "n", :n, "N", :N, "no", :no, "No", :No, "NO", :NO, ].freeze
- VERSION =
"0.2.1"
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
- .convert(value) ⇒ Object
- .On_Off(boolean) ⇒ Object
- .ON_OFF(boolean) ⇒ Object
- .on_off(boolean) ⇒ Object
- .one_zero(boolean) ⇒ Object
- .T_F(boolean) ⇒ Object
- .t_f(boolean) ⇒ Object
- .TRUE_FALSE(boolean) ⇒ Object
- .True_False(boolean) ⇒ Object
- .true_false(boolean) ⇒ Object
- .y_n(boolean) ⇒ Object
- .Y_N(boolean) ⇒ Object
- .yes_no(boolean) ⇒ Object
- .Yes_No(boolean) ⇒ Object
- .YES_NO(boolean) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(given = nil) ⇒ MuchBoolean
constructor
A new instance of MuchBoolean.
Constructor Details
#initialize(given = nil) ⇒ MuchBoolean
Returns a new instance of MuchBoolean.
105 106 107 108 |
# File 'lib/much-boolean.rb', line 105 def initialize(given = nil) @given = given @actual = self.class.convert(@given) end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
103 104 105 |
# File 'lib/much-boolean.rb', line 103 def actual @actual end |
#given ⇒ Object (readonly)
Returns the value of attribute given.
103 104 105 |
# File 'lib/much-boolean.rb', line 103 def given @given end |
Class Method Details
.convert(value) ⇒ Object
43 44 45 |
# File 'lib/much-boolean.rb', line 43 def self.convert(value) !FALSE_VALUES.include?(value) end |
.On_Off(boolean) ⇒ Object
75 76 77 |
# File 'lib/much-boolean.rb', line 75 def self.On_Off(boolean) Mapping.new(boolean, "On", "Off") end |
.ON_OFF(boolean) ⇒ Object
79 80 81 |
# File 'lib/much-boolean.rb', line 79 def self.ON_OFF(boolean) Mapping.new(boolean, "ON", "OFF") end |
.on_off(boolean) ⇒ Object
71 72 73 |
# File 'lib/much-boolean.rb', line 71 def self.on_off(boolean) Mapping.new(boolean, "on", "off") end |
.one_zero(boolean) ⇒ Object
47 48 49 |
# File 'lib/much-boolean.rb', line 47 def self.one_zero(boolean) Mapping.new(boolean, 1, 0) end |
.T_F(boolean) ⇒ Object
55 56 57 |
# File 'lib/much-boolean.rb', line 55 def self.T_F(boolean) Mapping.new(boolean, "T", "F") end |
.t_f(boolean) ⇒ Object
51 52 53 |
# File 'lib/much-boolean.rb', line 51 def self.t_f(boolean) Mapping.new(boolean, "t", "f") end |
.TRUE_FALSE(boolean) ⇒ Object
67 68 69 |
# File 'lib/much-boolean.rb', line 67 def self.TRUE_FALSE(boolean) Mapping.new(boolean, "TRUE", "FALSE") end |
.True_False(boolean) ⇒ Object
63 64 65 |
# File 'lib/much-boolean.rb', line 63 def self.True_False(boolean) Mapping.new(boolean, "True", "False") end |
.true_false(boolean) ⇒ Object
59 60 61 |
# File 'lib/much-boolean.rb', line 59 def self.true_false(boolean) Mapping.new(boolean, "true", "false") end |
.y_n(boolean) ⇒ Object
83 84 85 |
# File 'lib/much-boolean.rb', line 83 def self.y_n(boolean) Mapping.new(boolean, "y", "n") end |
.Y_N(boolean) ⇒ Object
87 88 89 |
# File 'lib/much-boolean.rb', line 87 def self.Y_N(boolean) Mapping.new(boolean, "Y", "N") end |
.yes_no(boolean) ⇒ Object
91 92 93 |
# File 'lib/much-boolean.rb', line 91 def self.yes_no(boolean) Mapping.new(boolean, "yes", "no") end |
Instance Method Details
#==(other) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/much-boolean.rb', line 110 def ==(other) actual == if other.is_a?(MuchBoolean) other.actual else other end end |