Guy's Hook Patch for Ruby 1.8

He said it was a toy, so I figured I would play with it. This patch provides a single colon of syntactic sugar for hooking a method. The hook is called before the method call.

 class Array
  def shift:hook()
   p "Removing #{self.first}" 
  end
 end

 arr = [1, 2, 3]
 arr.shift

The above prints Removing 1. You can run the original method with super.

Kinda interesting. It kind of sparks the mind to think what could be done if we were allowed to add code to blocks. In the case of a hook, we’re merely adding code to the beginning of a method. Hmm. I dunno.

Incident No. 16: The Skier

One man had become such an impulsive skier that he started skiing down dirt roads in the summer. It actually wasn’t such a bad sport and the guy won a silver medal when Dust Country Skiing went national.

The fashion these people wore was atrocious, though. It was common to see ski poles with leather tassles on the handles and such nonsense.

Incident No. 15: The Man Who Happened to Have Legs

One of the first strange things to ever happen was when a man was born and turned out to be nothing more than twelve legs coming from a cloud. When people saw him, they usually ended up thinking that he was David Blaine or some other magician pulling a stunt.

So David Blaine got a really bad rap about it and people started putting a lot of pressure on him to do regular card tricks that just told a story or something.

Incident No. 14: The Man Who Happened to Reach Up

There was a man who happened to reach up higher than anyone ever had before, so his hand got stuck in a cloud. And he got dragged all over the sky.

A lot of his old buddies really got a kick out of seeing him fly by whenever they showed weather maps on the news.

disoriented?

why the lucky stiff
is a fledgling freelance professor, one who will die young and make no lasting impression.

except there was that time when i vacuumed all of Greenland for them.

email? here.

Books:
  • Why's (Poignant) Guide to Ruby (Blixy Tees)

    Blogs:
  • quiet
  • Hackety Org
  • RedHanded COMPLETED!

    Stories:
  • The Bobby Wolves
  • Stunt Runner

    Comics:
  • Holy Bible: one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen
  • The Open Window: one, two, three, four, five, six, seven, eight, nine
  • Lost Children, Lost Children, Lost Children, See Such Feverish Castles: one


  • Incidents: (35) Adventure of the Apple's Mom (34) A Magic Milk (33) The Secret Sandwich (32) A Smart Curtsy (31) The Hand Which Fell Apart (30) Jentle & Pailey (29) The Grieving Boar (28) The Story Life Doesn't Explain (27) The Life Guy (26) The Jump Wanter (25) Kimothy's Mouth (24) Speaking Of Flutes (23) The Advisor (22) Wristwatches (21) The Queen-Sized (20) The Tandem Bicycle (19) The Little Piece of Cloth (18) Milk Powers (17) Javek and the Candle (16) The Skier (15) The Man Who Happened to Have Legs (14) The Man Who Happened to Reach Up (13) Duck Typing (12) The Incident (11) The End (10) Ghosts (9) The Man (8) Waking (7) Water (6) Birthstones (5) Ignored (4) The Berkowitz Manuevre (3) Regrets (2) Emptiness (1) The Milkman Who Couldn't Sleep

    Five-Minute Plays for Twins Who Don't Have Their Other Twin With Them and An Unlimited Supply of Animals: Octopus, Eagle, Swan, Otter

    Quatrains: 0.0, 0.1, 0.2, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5

    Hacking:
  • The Fully Upturned Bin
  • Seeing Metaclasses Clearly
  • What's Shiny and New in Ruby 1.8.0?
  • A Quick Guide to SQLite and Ruby
  • The Little Coder's Predicament
  • Wearing Ruby Slippers To Work

    Feeds:
  • RSS 2.0
  • Atom 0.3
  • !okay/news

    Hobix 0.4 is the white pantsuit underneath it all.