Class: RediSearch::Spellcheck::Result
- Inherits:
-
Object
- Object
- RediSearch::Spellcheck::Result
- Defined in:
- lib/redi_search/spellcheck/result.rb
Instance Attribute Summary collapse
-
#suggestions ⇒ Object
readonly
Returns the value of attribute suggestions.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
Instance Method Summary collapse
-
#initialize(term, suggestions) ⇒ Result
constructor
A new instance of Result.
- #inspect ⇒ Object
-
#pretty_print(printer) ⇒ Object
:nocov:.
Constructor Details
#initialize(term, suggestions) ⇒ Result
Returns a new instance of Result.
10 11 12 13 14 15 |
# File 'lib/redi_search/spellcheck/result.rb', line 10 def initialize(term, suggestions) @term = term @suggestions = suggestions.map do |suggestion| Suggestion.new(suggestion[0].to_f, suggestion[1]) end end |
Instance Attribute Details
#suggestions ⇒ Object (readonly)
Returns the value of attribute suggestions.
8 9 10 |
# File 'lib/redi_search/spellcheck/result.rb', line 8 def suggestions @suggestions end |
#term ⇒ Object (readonly)
Returns the value of attribute term.
8 9 10 |
# File 'lib/redi_search/spellcheck/result.rb', line 8 def term @term end |
Instance Method Details
#inspect ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/redi_search/spellcheck/result.rb', line 17 def inspect inspection = %w(term suggestions).filter_map do |field_name| "#{field_name}: #{public_send(field_name)}" end.join(", ") "#<#{self.class} #{inspection}>" end |
#pretty_print(printer) ⇒ Object
:nocov:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/redi_search/spellcheck/result.rb', line 26 def pretty_print(printer) # rubocop:disable Metrics/MethodLength printer.object_address_group(self) do printer.seplist( %w(term suggestions), proc { printer.text "," } ) do |field_name| printer.breakable " " printer.group(1) do printer.text field_name printer.text ":" printer.breakable printer.pp public_send(field_name) end end end end |