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
|
# File 'lib/kafo/data_types/numeric.rb', line 4
def typecast(value)
value =~ /\d+/ ? value.to_f : value
end
|
#valid?(input, errors = []) ⇒ Boolean
8
9
10
11
|
# File 'lib/kafo/data_types/numeric.rb', line 8
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
|