05 May 2012

I randomly decided to create a gem. I’m usually pretty bad at executing on my independent ideas for gems, but this on was so simple I didn’t have an excuse.

Luka simply adds a fluent interface on top of any object. It’s still a hatchling, so it doesn’t care about return values yet. I’m open to expanding its functionality, so if you have an idea, leave a comment.

http://sfsekaran.github.com/luka

You can use it like this:

class Words
  def initialize
    @sentence = []
  end

  def I
    @sentence << 'I'
  end

  def like
    @sentence << 'like'
  end

  def pie
    @sentence << 'pie'
  end

  def sentence
    @sentence.join(' ') + '.'
  end
end

include Luka

say = luka(Words.new)
say.I.like.pie

say.sentence # => "I like pie."

Enjoy!



blog comments powered by Disqus