Class: Kotoshu::Algorithms::Suggest::Suggestion
- Inherits:
-
Object
- Object
- Kotoshu::Algorithms::Suggest::Suggestion
- Defined in:
- lib/kotoshu/algorithms/suggest.rb
Overview
Represents a single word suggestion.
Suggestions are produced internally to store enough information to make sure it is a good one.
Instance Attribute Summary collapse
-
#kind ⇒ String
readonly
How suggestion was produced (same as method name).
-
#text ⇒ String
readonly
Actual suggestion text.
Instance Method Summary collapse
-
#initialize(text, kind) ⇒ Suggestion
constructor
A new instance of Suggestion.
-
#inspect ⇒ String
Inspect string.
-
#replace(**changes) ⇒ Suggestion
Create a copy with changes.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(text, kind) ⇒ Suggestion
Returns a new instance of Suggestion.
37 38 39 40 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 37 def initialize(text, kind) @text = text @kind = kind end |
Instance Attribute Details
#kind ⇒ String (readonly)
Returns How suggestion was produced (same as method name).
35 36 37 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 35 def kind @kind end |
#text ⇒ String (readonly)
Returns Actual suggestion text.
32 33 34 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 32 def text @text end |
Instance Method Details
#inspect ⇒ String
Inspect string.
63 64 65 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 63 def inspect "Suggestion[#{@kind}](#{@text.inspect})" end |
#replace(**changes) ⇒ Suggestion
Create a copy with changes.
46 47 48 49 50 51 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 46 def replace(**changes) self.class.new( changes.fetch(:text, @text), changes.fetch(:kind, @kind) ) end |
#to_s ⇒ String
String representation.
56 57 58 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 56 def to_s @text end |