Class: Attentive::Match
- Inherits:
-
Object
- Object
- Attentive::Match
- Defined in:
- lib/attentive/match.rb
Instance Attribute Summary collapse
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#phrase ⇒ Object
readonly
Returns the value of attribute phrase.
Instance Method Summary collapse
- #[](variable_name) ⇒ Object
-
#initialize(phrase, attributes = {}) ⇒ Match
constructor
A new instance of Match.
- #matched?(variable_name) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(phrase, attributes = {}) ⇒ Match
Returns a new instance of Match.
5 6 7 8 9 10 |
# File 'lib/attentive/match.rb', line 5 def initialize(phrase, attributes={}) @phrase = phrase.to_s @match_data = attributes.fetch(:match_data, {}) @listener = attributes[:listener] @message = attributes[:message] end |
Instance Attribute Details
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
3 4 5 |
# File 'lib/attentive/match.rb', line 3 def listener @listener end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/attentive/match.rb', line 3 def @message end |
#phrase ⇒ Object (readonly)
Returns the value of attribute phrase.
3 4 5 |
# File 'lib/attentive/match.rb', line 3 def phrase @phrase end |
Instance Method Details
#[](variable_name) ⇒ Object
16 17 18 |
# File 'lib/attentive/match.rb', line 16 def [](variable_name) @match_data.fetch variable_name.to_s end |
#matched?(variable_name) ⇒ Boolean
12 13 14 |
# File 'lib/attentive/match.rb', line 12 def matched?(variable_name) @match_data.key? variable_name.to_s end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/attentive/match.rb', line 20 def to_s @phrase end |