Class: Caty::BooleanConverter
- Defined in:
- lib/caty/converters.rb
Overview
Converter for boolean values:
%w(true false 1 0) << nil
Instance Method Summary collapse
Methods inherited from Converter
Instance Method Details
#convert(value) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/caty/converters.rb', line 49 def convert( value ) case value when 'true', '1', nil then true when 'false', '0' then false else e = Caty::OptionArgumentError.new e.expected = '0, 1, true, false or no argument' raise e end end |