Module: Alchemist::NumericExt

Included in:
Numeric
Defined in:
lib/alchemist/numeric_ext.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(unit_name, *args, &block) ⇒ Object



7
8
9
10
11
# File 'lib/alchemist/numeric_ext.rb', line 7

def method_missing unit_name, *args, &block
  exponent, unit_name = Alchemist.parse_prefix(unit_name)
  Conversions[ unit_name ] || super( unit_name, *args, &block )
  NumericConversion.new self, unit_name, exponent
end

Instance Method Details

#from(unit_name) ⇒ Object



3
4
5
# File 'lib/alchemist/numeric_ext.rb', line 3

def from(unit_name)
  send(unit_name)
end