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.
- Host: GitHub
- URL: https://github.com/pnc/matches
- Owner: pnc
- License: mit
- Created: 2009-10-23T02:15:02.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2009-10-27T01:39:49.000Z (over 16 years ago)
- Last Synced: 2025-03-05T03:46:47.172Z (over 1 year ago)
- Language: Ruby
- Homepage: http://wiki.github.com/pnc/matches
- Size: 97.7 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.