Class: Gorillib::Factory::IntegerFactory
- Inherits:
-
ConvertingFactory
- Object
- BaseFactory
- ConvertingFactory
- Gorillib::Factory::IntegerFactory
- Defined in:
- lib/gorillib/factories.rb
Overview
Note:
returns Bignum or Fixnum (instances of either are is_a?(Integer)
)
Converts arg to a Fixnum or Bignum.
- Numeric types are converted directly, with floating point numbers being truncated
- Strings are interpreted using
Integer()
, so: ** radix indicators (0, 0b, and 0x) are HONORED -- '011' means 9, not 11; '0x22' means 0, not 34 ** They must strictly conform to numeric representation or an error is raised (which differs from the behavior of String#to_i) - Non-string values will be converted using to_int, and to_i.
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from ConvertingFactory
Methods inherited from BaseFactory
#blankish?, blankish?, #initialize, #native?, native?, #receive, typename, #typename
Constructor Details
This class inherits a constructor from Gorillib::Factory::BaseFactory
Instance Method Details
#convert(obj) ⇒ Object
294 295 296 |
# File 'lib/gorillib/factories.rb', line 294 def convert(obj) Integer(obj) end |