Calamitas
6/16/2007 2:04:00 AM
On 16/06/07, Frew Schmidt <frioux@gmail.com> wrote:
> Thanks for the tips! I'll look into it for sure. I think that the
> stuff I am doing is simple enough that I can do it by hand (you know,
> minute = 60, hour = 60 * minute, use jurian dates, etc.) I don't know
> if something in my setup is broken or something, but the vast majority
> of the examples in the Doc didn't work at all. Here's what happened:
>
> >> 1.bit/s + 8.bytes/s
> NameError: undefined local variable or method `s' for main:Object
> from (irb):2
> >> (1.bit/s).to(byte/s)
> NameError: undefined local variable or method `s' for main:Object
> from (irb):3
> >> 1.mile.to(feet)
> NameError: undefined local variable or method `feet' for main:Object
> from (irb):4
> >> 1.acre.to(yd**2)
> NameError: undefined local variable or method `yd' for main:Object
> from (irb):5
> >> 1.acre.to(sq_yd)
> NameError: undefined local variable or method `sq_yd' for main:Object
> from (irb):6
> >> 1.gallon.to(self.L)
> NoMethodError: undefined method `L' for main:Object
> from (irb):7
> >> 1.lb.to(kg)
> NameError: undefined local variable or method `kg' for main:Object
> from (irb):8
> >> 1.m.s.to(m.s)
> NameError: undefined local variable or method `m' for main:Object
> from (irb):9
> >> 1.sq_mi.to(km**2)
> NameError: undefined local variable or method `km' for main:Object
> from (irb):10
> >> 1.mile.to(km)
> NameError: undefined local variable or method `km' for main:Object
> from (irb):11
> >> 1.usd.to(twd)
> NameError: undefined local variable or method `twd' for main:Object
> from (irb):12
>
>
>
> If I did like, 1.bit + 1.byte it would work, but the examples above all
> failed apparently.
You need to include the Units module first (this is to prevent
unwanted name space pollution):
>> require 'facets/more/units'
=> true
>> include Units
=> Object
>> 1.bit/s + 8.bytes/s
=> 65.0 bit/s
Note that the current version of Units contains a few embarrassing
bugs that should be removed in the next release (but when that is, is
not up to me). Also, last time I checked, the web service I used for
the currency conversion has ceased working.
Peter