Module: RubyUnits::Numeric
- Included in:
- Numeric
- Defined in:
- lib/ruby_units/numeric.rb
Overview
Extra methods for [::Numeric] to allow it to be used as a [RubyUnits::Unit]
Instance Method Summary collapse
-
#to_unit(other = nil) ⇒ RubyUnits::Unit
Make a unitless unit with a given scalar.
Instance Method Details
#to_unit(other = nil) ⇒ RubyUnits::Unit
Make a unitless unit with a given scalar. > In ruby-units <= 2.3.2 this method would create a new [RubyUnits::Unit] > with the scalar and passed in units. This was changed to be more > consistent with the behavior of [#to_unit]. Specifically the argument is > used as a convenience method to convert the unitless scalar unit to a > compatible unitless unit.
15 16 17 |
# File 'lib/ruby_units/numeric.rb', line 15 def to_unit(other = nil) other ? RubyUnits::Unit.new(self).convert_to(other) : RubyUnits::Unit.new(self) end |