top | dibdib: Random things | programming: Ruby  /  EDF  /  Palm  /  Perl | obsessions: Games | about: me  /  my pages  /  people

with.rb

source (example script)

A Ruby extension for the Object class that provides Object#with.

Tired of those workaday lists of method calls on the same object?

  myObj = SomeObject.new()

  # time passes...

  myObj.method()
  myObj.another_method()
  myObj.yet_another()
  myObj.boring()

Fret no more, for now you can do this!

  require "with"
  
  myObj = SomeObject.new()

  with (myObj) {
    method()
    another_method()
    yet_another()
    boring()
  }

Caveats