Class: AboutYou::SDK::Model::FacetGroup
- Inherits:
-
Object
- Object
- AboutYou::SDK::Model::FacetGroup
- Defined in:
- lib/AboutYou/Model/facet_group.rb
Overview
This class represents a facet group model
Instance Attribute Summary collapse
-
#facets ⇒ Object
Array of instances of AboutYou::SDK::Model::Facet.
-
#group_id ⇒ Object
id of the group of this facet group.
-
#id ⇒ Object
id of this facet group.
-
#name ⇒ Object
name of the facet group.
Instance Method Summary collapse
-
#add_facet(facet) ⇒ Object
this method adds a facet to the facet group.
-
#add_facets(facets) ⇒ Object
this method adds facets to the facet group.
-
#contains(facet) ⇒ Object
This method checks if this facet group contains a facet.
-
#equal?(facet_group) ⇒ Boolean
This method is used for checking whether a given facet group is equal to this facet group.
-
#facet_names(separator = '/') ⇒ Object
this method is used for getting all of the facet names of this facet group.
-
#ids ⇒ Object
Gett for the ids.
-
#initialize(id, name) ⇒ FacetGroup
constructor
Constructor for the AboutYou::SDK::Model::FacetGroup class.
-
#unique_key ⇒ Object
This method is used for creating a unique key for this facet group.
Constructor Details
#initialize(id, name) ⇒ FacetGroup
Constructor for the AboutYou::SDK::Model::FacetGroup class
-
Args :
-
id
-> the id of the facet group -
name
-> the name of the facet group
-
-
Returns :
-
an instance of AboutYou::SDK::Model::FacetGroup
-
27 28 29 30 31 32 33 |
# File 'lib/AboutYou/Model/facet_group.rb', line 27 def initialize(id, name) self.id = id self.name = name self.facets = {} self end |
Instance Attribute Details
#facets ⇒ Object
Array of instances of AboutYou::SDK::Model::Facet
9 10 11 |
# File 'lib/AboutYou/Model/facet_group.rb', line 9 def facets @facets end |
#group_id ⇒ Object
id of the group of this facet group
15 16 17 |
# File 'lib/AboutYou/Model/facet_group.rb', line 15 def group_id @group_id end |
#id ⇒ Object
id of this facet group
11 12 13 |
# File 'lib/AboutYou/Model/facet_group.rb', line 11 def id @id end |
#name ⇒ Object
name of the facet group
13 14 15 |
# File 'lib/AboutYou/Model/facet_group.rb', line 13 def name @name end |
Instance Method Details
#add_facet(facet) ⇒ Object
this method adds a facet to the facet group
-
Args :
-
facet
-> instance of AboutYou::SDK::Model::Facet which should be added
-
41 42 43 |
# File 'lib/AboutYou/Model/facet_group.rb', line 41 def add_facet(facet) facets[facet.id] = facet end |
#add_facets(facets) ⇒ Object
this method adds facets to the facet group
-
Args :
-
facets
-> Array containing instances of AboutYou::SDK::Model::Facet which should be added
-
51 52 53 54 55 |
# File 'lib/AboutYou/Model/facet_group.rb', line 51 def add_facets(facets) facets.each do |facet| add_facet(facet) end end |
#contains(facet) ⇒ Object
This method checks if this facet group contains a facet
-
Args :
-
facet
-> instance of AboutYou::SDK::Model::Facet
-
-
Returns :
-
Boolean determining whether this facet group contains the facet or not
-
124 125 126 |
# File 'lib/AboutYou/Model/facet_group.rb', line 124 def contains(facet) facets.key?(facet.id) end |
#equal?(facet_group) ⇒ Boolean
This method is used for checking whether a given facet group is equal to this facet group
-
Args :
-
facet_group
-> instance of AboutYou::SDK::Model::FacetGroup used for checking
-
-
Returns : -Boolean determining whether the facet groups are equal
86 87 88 89 90 |
# File 'lib/AboutYou/Model/facet_group.rb', line 86 def equal?(facet_group) return false unless id == facet_group.id unique_key == facet_group.unique_key end |
#facet_names(separator = '/') ⇒ Object
this method is used for getting all of the facet names of this facet group
-
Args :
-
separator
-> String controlling how the facet names should be seperated
-
-
Returns :
-
Array of Strings
-
66 67 68 69 70 71 72 73 74 |
# File 'lib/AboutYou/Model/facet_group.rb', line 66 def facet_names(separator = '/') names = [] facets.each do |facet| names.push(facet.name) end names.join(separator) names end |
#ids ⇒ Object
Gett for the ids
-
Returns :
-
Hash containing a pair of facet_group_id => Array of facet_ids
-
111 112 113 |
# File 'lib/AboutYou/Model/facet_group.rb', line 111 def ids { id => facets.keys } end |
#unique_key ⇒ Object
This method is used for creating a unique key for this facet group
-
Returns :
-
a String containing a unique key for this facet group
-
98 99 100 101 102 103 |
# File 'lib/AboutYou/Model/facet_group.rb', line 98 def unique_key facet_ids = facets.keys facet_ids.sort! String(id) + ':' + String(facet_ids.join(',')) end |