Class: Compendium::BooleanParam
- Defined in:
- lib/compendium/param_types.rb
Instance Method Summary collapse
-
#! ⇒ Object
When negating a BooleanParam, use the value instead.
- #boolean? ⇒ Boolean
-
#initialize(obj) ⇒ BooleanParam
constructor
A new instance of BooleanParam.
- #value ⇒ Object
Methods inherited from Param
#==, #date?, #dropdown?, #nil?, #radio?, #scalar?, #to_f, #to_i
Constructor Details
#initialize(obj) ⇒ BooleanParam
Returns a new instance of BooleanParam.
64 65 66 67 68 |
# File 'lib/compendium/param_types.rb', line 64 def initialize(obj, *) # If given 0, 1, or a version thereof (ie. "0"), pass it along return super obj.to_i if obj.numeric? && (0..1).cover?(obj.to_i) super !!obj ? 0 : 1 end |
Instance Method Details
#! ⇒ Object
When negating a BooleanParam, use the value instead
79 80 81 |
# File 'lib/compendium/param_types.rb', line 79 def ! !value end |
#boolean? ⇒ Boolean
70 71 72 |
# File 'lib/compendium/param_types.rb', line 70 def boolean? true end |
#value ⇒ Object
74 75 76 |
# File 'lib/compendium/param_types.rb', line 74 def value [true, false][self] end |