Class: Erlectricity::Matcher
- Inherits:
-
Object
- Object
- Erlectricity::Matcher
- Defined in:
- lib/erlectricity/matcher.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
Instance Method Summary collapse
-
#initialize(parent, condition, block) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(arg) ⇒ Boolean
- #run(arg) ⇒ Object
Constructor Details
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/erlectricity/matcher.rb', line 3 def block @block end |
#condition ⇒ Object
Returns the value of attribute condition.
3 4 5 |
# File 'lib/erlectricity/matcher.rb', line 3 def condition @condition end |
#receiver ⇒ Object
Returns the value of attribute receiver.
4 5 6 |
# File 'lib/erlectricity/matcher.rb', line 4 def receiver @receiver end |
Instance Method Details
#matches?(arg) ⇒ Boolean
17 18 19 |
# File 'lib/erlectricity/matcher.rb', line 17 def matches?(arg) @condition.satisfies?(arg) end |
#run(arg) ⇒ Object
12 13 14 15 |
# File 'lib/erlectricity/matcher.rb', line 12 def run(arg) args = @condition.binding_for(arg) block.call(*args) end |