Class: LetsShopMapper::Model::Suggest::Item
- Inherits:
-
Object
- Object
- LetsShopMapper::Model::Suggest::Item
- Defined in:
- lib/letsshop_mapper/model/suggest/item.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#nhits ⇒ Object
readonly
Returns the value of attribute nhits.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(item = nil) ⇒ Item
constructor
A new instance of Item.
- #parse(item) ⇒ Object
- #to_s(localtime = true) ⇒ Object
Constructor Details
#initialize(item = nil) ⇒ Item
Returns a new instance of Item.
10 11 12 13 |
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 10 def initialize(item = nil) @text, @type, @nhits, @filter = nil parse(item) if item end |
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
8 9 10 |
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 8 def filter @filter end |
#nhits ⇒ Object (readonly)
Returns the value of attribute nhits.
7 8 9 |
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 7 def nhits @nhits end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 5 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 6 def type @type end |
Instance Method Details
#parse(item) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 15 def parse(item) @text = item.at('text').text @type = item.at('text')['type'] @nhits = item.at('nhits').text @filter = Base::Filter::new(item.at('filter')['value']) end |
#to_s(localtime = true) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 22 def to_s(localtime = true) s = '' s += "Text: #{@text}\n" s += "Type: #{@type}\n" s += "NHits: #{@nhits}\n" s += "Filter: \n#{@filter}\n" end |