Class: Rulebook
- Inherits:
-
Object
- Object
- Rulebook
- Defined in:
- lib/rulebook.rb
Defined Under Namespace
Classes: Rule
Constant Summary collapse
- VERSION =
"0.5.0"
Instance Attribute Summary collapse
-
#rules ⇒ Object
Returns the value of attribute rules.
Instance Method Summary collapse
-
#[](query) ⇒ Object
(also: #rules_that_match_against, #match)
alias_method :<<.
- #add(regexp, &block) ⇒ Object
-
#initialize ⇒ Rulebook
constructor
A new instance of Rulebook.
Constructor Details
#initialize ⇒ Rulebook
Returns a new instance of Rulebook.
29 30 31 |
# File 'lib/rulebook.rb', line 29 def initialize @rules = [] end |
Instance Attribute Details
#rules ⇒ Object
Returns the value of attribute rules.
27 28 29 |
# File 'lib/rulebook.rb', line 27 def rules @rules end |
Instance Method Details
#[](query) ⇒ Object Also known as: rules_that_match_against, match
alias_method :<<. :add
38 39 40 |
# File 'lib/rulebook.rb', line 38 def [](query) @rules.find_all { |rule| rule.matches?(query) } end |