# Stupid question about the Stick gem

**URL:** <https://www.ruby-forum.com/t/stupid-question-about-the-stick-gem/134730>\
**Category:** Ruby\
**Created:** [April 14, 2008, 3:30pm UTC](https://www.ruby-forum.com/t/stupid-question-about-the-stick-gem/134730 "2008-04-14T15:30:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_TSRichter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@Michael\_TSRichter](https://www.ruby-forum.com/u/Michael_TSRichter)\
**Post date:** [April 14, 2008, 3:30pm UTC](https://www.ruby-forum.com/t/stupid-question-about-the-stick-gem/134730/1 "2008-04-14T15:30:03Z")

</div>

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](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(yd**2)  
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 method `s’ 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 method `yd’ 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 method `L’ 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 method `m’ 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 method `km’ 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?

---

<div class="post-metadata">

**Author:** ![Michael\_TSRichter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@Michael\_TSRichter](https://www.ruby-forum.com/u/Michael_TSRichter)\
**Post date:** [April 14, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/stupid-question-about-the-stick-gem/134730/2 "2008-04-14T16:10:53Z")

</div>

On Apr 14, 9:29 am, “Michael T. Richter” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![Michael\_TSRichter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@Michael\_TSRichter](https://www.ruby-forum.com/u/Michael_TSRichter)\
**Post date:** [April 14, 2008, 4:14pm UTC](https://www.ruby-forum.com/t/stupid-question-about-the-stick-gem/134730/3 "2008-04-14T16:14:58Z")

</div>

On Mon, Apr 14, 2008 at 4:09 PM, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![Michael\_TSRichter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@Michael\_TSRichter](https://www.ruby-forum.com/u/Michael_TSRichter)\
**Post date:** [April 14, 2008, 4:23pm UTC](https://www.ruby-forum.com/t/stupid-question-about-the-stick-gem/134730/4 "2008-04-14T16:23:12Z")

</div>

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! 😃

> 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.)
