Class: Kafo::DataTypes::Boolean
Instance Method Summary
collapse
#condition_value, #dump_default, #multivalued?, new_from_string, parse_hash, register_type, split_arguments, #to_s, types, unregister_type
Instance Method Details
#typecast(value) ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/kafo/data_types/boolean.rb', line 4
def typecast(value)
case value
when '0', 'false', 'f', 'n', false
false
when '1', 'true', 't', 'y', true
true
else
value
end
end
|
#valid?(input, errors = []) ⇒ Boolean
15
16
17
18
19
|
# File 'lib/kafo/data_types/boolean.rb', line 15
def valid?(input, errors = [])
(input.is_a?(::TrueClass) || input.is_a?(::FalseClass)).tap do |valid|
errors << "#{input.inspect} is not a valid boolean" unless valid
end
end
|