Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/van/units/base.rb
Direct Known Subclasses
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &blk) ⇒ Object
961 962 963 964 965 966 967 968 969 970 971 972 |
# File 'lib/van/units/base.rb', line 961 def method_missing(m, *args, &blk) if args.length == 1 args[0] = (Van::Units::Converter.converter(args[0]) rescue nil) if not args[0].is_a?(Van::Units::Converter) return Van::Units::Value.new(self, Van::Units::Unit.new({m => 1}, args[0])) if args[0] && args[0].registered?(m) elsif Van::Units::Converter.current.registered?(m) raise ::ArgumentError, "Wrong number of arguments" if args.length != 0 return Van::Units::Value.new(self, Van::Units::Unit.new({m => 1}, Van::Units::Converter.current)) end ::Exception.with_clean_backtrace("method_missing") { super } end |