Class: Match
Instance Attribute Summary collapse
-
#choice ⇒ Object
Returns the value of attribute choice.
-
#matching_range ⇒ Object
Returns the value of attribute matching_range.
-
#original_choice ⇒ Object
Returns the value of attribute original_choice.
-
#score ⇒ Object
Returns the value of attribute score.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#choice ⇒ Object
Returns the value of attribute choice
371 372 373 |
# File 'lib/selecta.rb', line 371 def choice @choice end |
#matching_range ⇒ Object
Returns the value of attribute matching_range
371 372 373 |
# File 'lib/selecta.rb', line 371 def matching_range @matching_range end |
#original_choice ⇒ Object
Returns the value of attribute original_choice
371 372 373 |
# File 'lib/selecta.rb', line 371 def original_choice @original_choice end |
#score ⇒ Object
Returns the value of attribute score
371 372 373 |
# File 'lib/selecta.rb', line 371 def score @score end |
Class Method Details
.trivial(choice) ⇒ Object
372 373 374 375 |
# File 'lib/selecta.rb', line 372 def self.trivial(choice) empty_range = (0...0) new(choice, choice.downcase, 0, empty_range) end |
Instance Method Details
#refine(score, range) ⇒ Object
388 389 390 |
# File 'lib/selecta.rb', line 388 def refine(score, range) Match.new(original_choice, choice, score, range) end |
#to_text ⇒ Object
377 378 379 380 381 382 383 384 385 386 |
# File 'lib/selecta.rb', line 377 def to_text if matching_range.none? Text[original_choice] else before = original_choice[0...matching_range.begin] matching = original_choice[matching_range.begin..matching_range.end] after = original_choice[(matching_range.end + 1)..-1] Text[before, :red, matching, :default, after] end end |