Class: HintableLevenshtein::RuleSet
- Inherits:
-
Object
- Object
- HintableLevenshtein::RuleSet
- Includes:
- Comparable
- Defined in:
- lib/hintable_levenshtein/rule_set.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
-
#initialize(score, *rules) ⇒ RuleSet
constructor
A new instance of RuleSet.
- #match?(events) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(score, *rules) ⇒ RuleSet
Returns a new instance of RuleSet.
7 8 9 10 |
# File 'lib/hintable_levenshtein/rule_set.rb', line 7 def initialize(score, *rules) @rules = rules @score = score end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
6 7 8 |
# File 'lib/hintable_levenshtein/rule_set.rb', line 6 def rules @rules end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
6 7 8 |
# File 'lib/hintable_levenshtein/rule_set.rb', line 6 def score @score end |
Instance Method Details
#match?(events) ⇒ Boolean
16 17 18 19 20 21 22 |
# File 'lib/hintable_levenshtein/rule_set.rb', line 16 def match?(events) return if events.size != rules.size events.each_with_index do |e, idx| return unless rules[idx].match?(e) end true end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/hintable_levenshtein/rule_set.rb', line 12 def to_s "#{score} -> #{rules.collect{|r| r.to_s} * ', '}" end |