Class: Symbol

Inherits:
Object show all
Defined in:
lib/homeschool.rb

Class Method Summary collapse

Class Method Details

.pattern(name, pattern, &formation) ⇒ Object



8
9
10
11
# File 'lib/homeschool.rb', line 8

def self.pattern(name, pattern, &formation)
  define_method(name) {to_s.match(pattern) ? self : formation.call(self).to_sym}
  define_method(name.question) {to_s.match(pattern)}
end