module Mongoid::Criteria::Queryable::Extensions::Numeric::ClassMethods
Public Instance Methods
__numeric__(object)
click to toggle source
Get the object as a numeric.
@api private
@example Get the object as numeric.
Object.__numeric__("1.442")
@param [ Object
] object The object to convert.
@return [ Object
] The converted number.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/numeric.rb, line 62 def __numeric__(object) object.to_s =~ /(\A[-+]?[0-9]+\z)|(\.0+\z)|(\.\z)/ ? object.to_i : Float(object) end
evolve(object)
click to toggle source
Evolve the object to an integer.
@example Evolve to integers.
Integer.evolve("1")
@param [ Object
] object The object to evolve.
@return [ Integer ] The evolved object.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/numeric.rb, line 76 def evolve(object) __evolve__(object) do |obj| __numeric__(obj) rescue obj end end