Class: SnFoil::Searcher::Boolean
- Inherits:
-
Object
- Object
- SnFoil::Searcher::Boolean
- Defined in:
- lib/snfoil/searcher/boolean.rb
Overview
A class that behaves like a boolean type, including rules for coercion of user input.
Coercion
-
“false”, “f” , “0”,
0
or any other value inFALSE_VALUES
will be coerced tofalse
-
Empty strings are coerced to
nil
-
All other values will be coerced to
true
Constant Summary collapse
- FALSE_VALUES =
rubocop:disable Lint/BooleanSymbol
[ false, 0, '0', :'0', 'f', :f, 'F', :F, 'false', :false, 'FALSE', :FALSE, 'off', :off, 'OFF', :OFF, '', nil ].to_set.freeze
Instance Method Summary collapse
-
#cast(value) ⇒ Object
rubocop:enable Lint/BooleanSymbol.
Instance Method Details
#cast(value) ⇒ Object
rubocop:enable Lint/BooleanSymbol
51 52 53 |
# File 'lib/snfoil/searcher/boolean.rb', line 51 def cast(value) !FALSE_VALUES.include?(value) end |