Class: Gorillib::Factory::RationalFactory
- Inherits:
-
ConvertingFactory
- Object
- BaseFactory
- ConvertingFactory
- Gorillib::Factory::RationalFactory
- Defined in:
- lib/gorillib/factories.rb
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
421 422 423 424 425 426 427 428 429 |
# File 'lib/gorillib/factories.rb', line 421 def convert(obj) if obj.respond_to?(:to_ary) x_y = obj.to_ary mismatched!(obj, "expected tuple to be a pair") unless (x_y.length == 2) Rational(* x_y) else Rational(obj) end end |