Class: Adhearsion::VoIP::CalculatedMatch
- Defined in:
- lib/adhearsion/voip/menu_state_machine/calculated_match.rb
Instance Attribute Summary collapse
-
#exact_matches ⇒ Object
readonly
Returns the value of attribute exact_matches.
-
#match_payload ⇒ Object
readonly
Returns the value of attribute match_payload.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#potential_matches ⇒ Object
readonly
Returns the value of attribute potential_matches.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Class Method Summary collapse
-
.failed_match!(pattern, query, match_payload) ⇒ Object
Convenience method for instantiating failed matches.
Instance Method Summary collapse
- #exact_match? ⇒ Boolean
- #failed_match? ⇒ Boolean
-
#initialize(options = {}) ⇒ CalculatedMatch
constructor
A new instance of CalculatedMatch.
- #potential_match? ⇒ Boolean
- #type_of_match ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CalculatedMatch
Returns a new instance of CalculatedMatch.
12 13 14 15 16 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 12 def initialize(={}) @pattern, @query, @match_payload = .values_at :pattern, :query, :match_payload @potential_matches = [:potential_matches] ? Array([:potential_matches]) : [] @exact_matches = [:exact_matches] ? Array([:exact_matches]) : [] end |
Instance Attribute Details
#exact_matches ⇒ Object (readonly)
Returns the value of attribute exact_matches.
10 11 12 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 10 def exact_matches @exact_matches end |
#match_payload ⇒ Object (readonly)
Returns the value of attribute match_payload.
10 11 12 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 10 def match_payload @match_payload end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
10 11 12 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 10 def pattern @pattern end |
#potential_matches ⇒ Object (readonly)
Returns the value of attribute potential_matches.
10 11 12 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 10 def potential_matches @potential_matches end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
10 11 12 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 10 def query @query end |
Class Method Details
.failed_match!(pattern, query, match_payload) ⇒ Object
Convenience method for instantiating failed matches
6 7 8 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 6 def self.failed_match!(pattern, query, match_payload) new :pattern => pattern, :query => query, :match_payload => match_payload end |
Instance Method Details
#exact_match? ⇒ Boolean
18 19 20 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 18 def exact_match? exact_matches.any? end |
#failed_match? ⇒ Boolean
26 27 28 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 26 def failed_match? !potential_match? && !exact_match? end |
#potential_match? ⇒ Boolean
22 23 24 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 22 def potential_match? potential_matches.any? end |
#type_of_match ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/adhearsion/voip/menu_state_machine/calculated_match.rb', line 30 def type_of_match if exact_match? :exact elsif potential_match? :potential end end |