class Kafo::DataTypes::Numeric

Public Instance Methods

typecast(value) click to toggle source
# File lib/kafo/data_types/numeric.rb, line 4
def typecast(value)
  Float(value)
rescue TypeError, ArgumentError
  value
end
valid?(input, errors = []) click to toggle source
# 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