Module: Origin::Extensions::Numeric::ClassMethods
- Defined in:
- lib/origin/extensions/numeric.rb
Instance Method Summary collapse
-
#__numeric__(object) ⇒ Object
private
Get the object as a numeric.
-
#evolve(object) ⇒ Integer
Evolve the object to an integer.
Instance Method Details
#__numeric__(object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the object as a numeric.
58 59 60 |
# File 'lib/origin/extensions/numeric.rb', line 58 def __numeric__(object) object.to_s =~ /(^[-+]?[0-9]+$)|(\.0+$)|(\.$)/ ? object.to_i : Float(object) end |
#evolve(object) ⇒ Integer
Evolve the object to an integer.
72 73 74 75 76 |
# File 'lib/origin/extensions/numeric.rb', line 72 def evolve(object) __evolve__(object) do |obj| __numeric__(obj) rescue obj end end |