Class: Kafo::DataTypes::Numeric
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
|
# File 'lib/kafo/data_types/numeric.rb', line 4
def typecast(value)
Float(value)
rescue TypeError, ArgumentError
value
end
|
#valid?(input, errors = []) ⇒ Boolean
10
11
12
13
|
# File 'lib/kafo/data_types/numeric.rb', line 10
def valid?(input, errors = [])
errors << "#{input.inspect} is not a valid number" unless input.is_a?(::Integer) || input.is_a?(::Float)
return errors.empty?
end
|