lib/units/numeric.rb
# Handle conversion methods (to_*) and pass everything else to the wrapped value
Handle conversion methods (to_*) and pass everything else to the wrapped value
Handle conversion methods ( to_ * ) and pass everything else to the wrapped value
def method_missing(id, *args)
	    if (id.to_s =~ /(.+)\?$/) and Units.valid_unit?($1)
		@units.is_a?($1)
	    elsif @units.valid_conversion?(id)
		units = Units.new(id)
		(@units == units) ? self : self.class.new(@units.convert(@value, id), units)
	    elsif (id.to_s =~ /^to_(.+)$/) and Units.valid_unit?($1)
		units = Units.new($1)
		return self if @units == units
		self.class.new(@units.convert(@value, $1), units)
	    else
		@value.send(id, *args)
	    end
	end
def method_missing ( id , * args ) if ( id . to_s =~ / (.+) \? $ / ) and Units . valid_unit? ( $1 ) @units . is_a? ( $1 ) elsif @units . valid_conversion? ( id ) units = Units . new ( id ) ( @units == units ) ? self : self . class . new ( @units . convert ( @value , id ) , units ) elsif ( id . to_s =~ / ^to_(.+)$ / ) and Units . valid_unit? ( $1 ) units = Units . new ( $1 ) return self if @units == units self . class . new ( @units . convert ( @value , $1 ) , units ) else @value . send ( id , * args ) end end
Handle conversion methods (to_*) and pass everything else to the wrapped value
Handle conversion methods ( to_ * ) and pass everything else to the wrapped value
# Check this before valid_conversion? because valid_conversion? has low standards
id
<not_specific>
args
<not_specific>