Class: Velocity::Instance::Dictionary::AutocompleteSuggestion
- Inherits:
-
Object
- Object
- Velocity::Instance::Dictionary::AutocompleteSuggestion
- Defined in:
- lib/acceleration/velocity.rb
Overview
A simple wrapper for an autocomplete suggestion
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
The number of occurrences.
-
#doc ⇒ Object
The xml.
-
#phrase ⇒ Object
readonly
The phrase.
Class Method Summary collapse
-
.new_from_xml(xml) ⇒ Object
Create a new suggestion given some XML from Velocity.
Instance Method Summary collapse
-
#initialize(phrase, count = 0, xml = nil) ⇒ AutocompleteSuggestion
constructor
Create a new suggestion.
-
#to_s ⇒ Object
This is really only ever going to be used as a string.
Constructor Details
#initialize(phrase, count = 0, xml = nil) ⇒ AutocompleteSuggestion
Create a new suggestion
1200 1201 1202 1203 1204 |
# File 'lib/acceleration/velocity.rb', line 1200 def initialize(phrase, count = 0, xml = nil) @phrase = phrase @count = count @doc = xml end |
Instance Attribute Details
#count ⇒ Object (readonly)
The number of occurrences
1198 1199 1200 |
# File 'lib/acceleration/velocity.rb', line 1198 def count @count end |
#doc ⇒ Object
The xml
1194 1195 1196 |
# File 'lib/acceleration/velocity.rb', line 1194 def doc @doc end |
#phrase ⇒ Object (readonly)
The phrase
1196 1197 1198 |
# File 'lib/acceleration/velocity.rb', line 1196 def phrase @phrase end |
Class Method Details
.new_from_xml(xml) ⇒ Object
Create a new suggestion given some XML from Velocity
1207 1208 1209 1210 1211 1212 1213 |
# File 'lib/acceleration/velocity.rb', line 1207 def self.new_from_xml(xml) AutocompleteSuggestion.new( xml.children.first.text, xml.attributes['count'].value.to_i, xml ) end |
Instance Method Details
#to_s ⇒ Object
This is really only ever going to be used as a string
1216 1217 1218 |
# File 'lib/acceleration/velocity.rb', line 1216 def to_s phrase end |