Class: LetsShopMapper::Model::Base::Facet
- Inherits:
-
Object
- Object
- LetsShopMapper::Model::Base::Facet
- Defined in:
- lib/letsshop_mapper/model/base/facet.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#nhits ⇒ Object
readonly
Returns the value of attribute nhits.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#selected ⇒ Object
readonly
Returns the value of attribute selected.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(facet = nil) ⇒ Facet
constructor
A new instance of Facet.
- #parse(facet) ⇒ Object
- #to_s(localtime = true) ⇒ Object
Constructor Details
#initialize(facet = nil) ⇒ Facet
Returns a new instance of Facet.
13 14 15 16 17 18 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 13 def initialize(facet = nil) @xml = facet @title, @type, @filter, @role, @selected, @nhits = nil @selected = false parse(facet) if facet end |
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
7 8 9 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 7 def filter @filter end |
#nhits ⇒ Object (readonly)
Returns the value of attribute nhits.
10 11 12 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 10 def nhits @nhits end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
8 9 10 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 8 def role @role end |
#selected ⇒ Object (readonly)
Returns the value of attribute selected.
9 10 11 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 9 def selected @selected end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 5 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 6 def type @type end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
11 12 13 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 11 def xml @xml end |
Instance Method Details
#parse(facet) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 20 def parse(facet) @title = facet['title'].split(":")[1] @type = facet['title'].split(":")[0] @filter = Filter::new(facet['title']) @role = facet['role'] if facet['nhits'] @nhits = facet['nhits'] end if facet['selected'] @selected = LetsShopMapper.Boolean(facet['selected']) end end |
#to_s(localtime = true) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/letsshop_mapper/model/base/facet.rb', line 33 def to_s(localtime = true) s = '' s += "Title: #{@title}\n" s += "Type: #{@type}\n" s += "Filter: #{@filter.str_value}\n" s += "Role: #{@role}\n" s += "Selected: #{@selected}\n" s += "nhits: #{@nhits}\n" s += "\n" end |