Module: NumericWithUnit::NumUtil
- Defined in:
- lib/numeric_with_unit/util.rb,
lib/numeric_with_unit/util2.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/numeric_with_unit/util2.rb', line 44
def method_missing(name, *args)
if args.empty?
unit_str = name.to_s.gsub('_', '/')
self.to_nwu(unit_str)
else
raise Unit::NoUnitError
end
rescue Unit::NoUnitError
super
end
|
Instance Method Details
#[](unit) ⇒ Object
10
11
12
|
# File 'lib/numeric_with_unit/util.rb', line 10
def [](unit)
NumericWithUnit.new(self, unit)
end
|