Project

matches

0.0
No commit activity in last 3 years
No release in over 3 years
Matches allows you to define methods that have regular expressions rather than names, and automatically configires method_missing to handle them.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9
 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 to learn more.