An open API service indexing awesome lists of open source software.

https://github.com/pnc/matches

An easy means of defining meta-methods in Ruby.
https://github.com/pnc/matches

Last synced: about 1 year ago
JSON representation

An easy means of defining meta-methods in Ruby.

Awesome Lists containing this project

README

          

Matches – easygoing methods
===========================

Matches is an easy DSL for defining regular-expression-based methods in Ruby.

Start playing with matches:

# If needed
sudo gem install gemcutter
gem tumble

sudo gem install matches

Then, in a Ruby file somewhere:

require 'rubygems'
require 'matches'

class Hippo
def initialize
@verbs = []
end

matches /^(\w+)\!$/ do |verb|
@verbs << verb
end

matches /^(\w+)ed\?$/ do |verb|
@verbs.include?(verb)
end
end

herman = Hippo.new
herman.fatten!
herman.touch!

herman.touched?
==> true

[Read the guide](http://wiki.github.com/pnc/matches) to learn more.