Module: Diamond::Pattern::ClassMethods
- Included in:
- Diamond::Pattern
- Defined in:
- lib/diamond/pattern.rb
Instance Method Summary collapse
-
#<<(pattern) ⇒ Array<Pattern>
Add a pattern.
-
#add(*args, &block) ⇒ Array<Pattern>
Construct and add a pattern.
-
#all ⇒ Array<Pattern>
All patterns.
-
#find(name) ⇒ Pattern
Find a pattern by its name (case insensitive).
- #first ⇒ Pattern
- #last ⇒ Pattern
Instance Method Details
#<<(pattern) ⇒ Array<Pattern>
Add a pattern
32 33 34 |
# File 'lib/diamond/pattern.rb', line 32 def <<(pattern) all << pattern end |
#add(*args, &block) ⇒ Array<Pattern>
Construct and add a pattern
25 26 27 |
# File 'lib/diamond/pattern.rb', line 25 def add(*args, &block) all << new(*args, &block) end |
#all ⇒ Array<Pattern>
All patterns
10 11 12 |
# File 'lib/diamond/pattern.rb', line 10 def all @patterns ||= [] end |
#find(name) ⇒ Pattern
Find a pattern by its name (case insensitive)
17 18 19 |
# File 'lib/diamond/pattern.rb', line 17 def find(name) all.find { |pattern| pattern.name.to_s.downcase == name.to_s.downcase } end |