lib/phys/units/unit_class.rb in phys-units-0.9.1 vs lib/phys/units/unit_class.rb in phys-units-0.9.2

- old
+ new

@@ -48,15 +48,16 @@ Unit.new(x) end end def word(x) - find_unit(x) || define(x) + find_unit(x) or raise UnitError, "Undefined unit: #{x.inspect}" + #find_unit(x) || define(x,nil) end def parse(x) - find_unit(x) || Parse.new.parse(x) + find_unit(x) || Unit.cast(Parse.new.parse(x)) end def find_unit(x) if Numeric===x Unit.new(x) @@ -69,12 +70,12 @@ end alias [] find_unit def unit_stem(x) - ( /(.{3,}(?:s|z|ch))es$/ =~ x && LIST[$1] ) || - ( /(.{3,})s$/ =~ x && LIST[$1] ) + ( /(.{2,}(?:s|z|ch))es$/ =~ x && LIST[$1] ) || + ( /(.{2,})s$/ =~ x && LIST[$1] ) end def find_prefix(x) Unit.prefix_regex =~ x pre,post = $1,$2 @@ -84,10 +85,10 @@ end #-- def unit_chars - '\\s*+\\/0-9<=>()\\[\\]^{|}~\\\\' + '\\s*+\\/<=>()\\[\\]^{|}~\\\\' end def control_units_dat(var,skip,line) case line when /!\s*end(\w+)/