Stupid question about the Stick gem

So, I installed the stick gem and gave it a run through its paces. I
stumbled at the first hurdle. From the documentation found at
http://stick.rubyforge.org/rdoc/index.html” I get the following snippet
of code (the obvious spelling error of “require” corrected):

require ‘stick/units’
1.bit/s + 8.bytes/s
(1.bit/s).to(byte/s)
1.mile.to(feet)
1.acre.to(yd2)
1.acre.to(sq_yd)
1.gallon.to(self.L)
1.lb.to(kg)
1.m.s.to(m.s)
1.sq_mi.to(km
2)
1.mile.to(km)
1.usd.to(twd)

Cutting and pasting that very code into irb:

irb(main):003:0> require ‘stick/units’
=> false
irb(main):004:0> 1.bit/s + 8.bytes/s
NameError: undefined local variable or method s' for main:Object from (irb):4 irb(main):005:0> (1.bit/s).to(byte/s) NameError: undefined local variable or methods’ for main:Object
from (irb):5
irb(main):006:0> 1.mile.to(feet)
NameError: undefined local variable or method feet' for main:Object from (irb):6 irb(main):007:0> 1.acre.to(yd**2) NameError: undefined local variable or methodyd’ for main:Object
from (irb):7
irb(main):008:0> 1.acre.to(sq_yd)
NameError: undefined local variable or method sq_yd' for main:Object from (irb):8 irb(main):009:0> 1.gallon.to(self.L) NoMethodError: undefined methodL’ for main:Object
from (irb):9
irb(main):010:0> 1.lb.to(kg)
NameError: undefined local variable or method kg' for main:Object from (irb):10 irb(main):011:0> 1.m.s.to(m.s) NameError: undefined local variable or methodm’ for main:Object
from (irb):11
irb(main):012:0> 1.sq_mi.to(km**2)
NameError: undefined local variable or method km' for main:Object from (irb):12 irb(main):013:0> 1.mile.to(km) NameError: undefined local variable or methodkm’ for main:Object
from (irb):13
irb(main):014:0> 1.usd.to(twd)
NoMethodError: undefined method `usd’ for 1:Fixnum
from (irb):14

Not a single one of the supplied examples works. Digging around in the
docs more closely finds me nothing to show what went wrong and the
source isn’t helping a whole lot either. So what’s the magic trick to
get stick to work?

On Apr 14, 9:29 am, “Michael T. Richter” [email protected] wrote:

Not a single one of the supplied examples works. Digging around in the
docs more closely finds me nothing to show what went wrong and the
source isn’t helping a whole lot either. So what’s the magic trick to
get stick to work?

include Stick::Units

Thanks for the documentation catch I’ll fix that.

T.

On Mon, Apr 14, 2008 at 4:09 PM, Trans [email protected] wrote:

include Stick::Units

Thanks for the documentation catch I’ll fix that.

(You just beat me to it…)

While you’re at it, could you remove the last line from that example
(1.usd.to(twd)) because it is specific to currencies and not included
by ‘stick/units’. Thanks.

Peter

On Mon, 2008-04-14 at 23:09 +0900, Trans wrote:

So what’s the magic trick to get stick to work?

include Stick::Units

That’s definitely magical! :smiley:

Thanks for the documentation catch I’ll fix that.

Not a problem. Do you take feature requests? I’d like to be able to
convert velocities to furlongs per fortnight. If you can’t/won’t add
that yourself, could you point me to docs which give me an overview of
adding my own units?

(Hint: this is a joke request. I just want to calculate the speed of
light in furlongs per fortnight for my own twisted amusement.)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs