Class: LetsShopMapper::Model::Suggest::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/letsshop_mapper/model/suggest/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#filterObject (readonly)

Returns the value of attribute filter.



8
9
10
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 8

def filter
  @filter
end

#nhitsObject (readonly)

Returns the value of attribute nhits.



7
8
9
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 7

def nhits
  @nhits
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/letsshop_mapper/model/suggest/item.rb', line 5

def text
  @text
end

#typeObject (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