Class: Ariel::Wildcards
- Inherits:
-
Object
- Object
- Ariel::Wildcards
- Defined in:
- lib/ariel/wildcards.rb
Overview
Contains all wildcards to be used in rule generation.
Constant Summary collapse
- @@list =
{ :anything=>/.+/, :numeric=>/\d+/, :alpha_numeric=>/\w+/, :alpha=>/[[:alpha:]]+/, :capitalized=>/[[:upper:]]+\w+/, :all_caps=>/[[:upper:]]+/, :html_tag=>/<\/?\w+>|<\w+\s+\/>/, :punctuation=>/[[:punct:]]+/ }
Class Method Summary collapse
-
.list ⇒ Object
Returns the hash of wildcard name (symbol) and regular expression pairs.
-
.matching(string) ⇒ Object
Given a string, will return an array of symbols from Wildcards::list that match it.
Class Method Details
.list ⇒ Object
Returns the hash of wildcard name (symbol) and regular expression pairs.
16 17 18 |
# File 'lib/ariel/wildcards.rb', line 16 def self.list @@list end |
.matching(string) ⇒ Object
Given a string, will return an array of symbols from Wildcards::list that match it.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ariel/wildcards.rb', line 22 def self.matching(string) matches=[] @@list.each do |name, regex| if string[regex]==string yield name if block_given? matches << name end end matches end |