class AboutYou::SDK::Model::FacetGroup
This class represents a facet group model
Attributes
Array of instances of AboutYou::SDK::Model::Facet
id of the group of this facet group
id of this facet group
name of the facet group
Public Class Methods
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
-
# File lib/AboutYou/Model/facet_group.rb, line 27 def initialize(id, name) self.id = id self.name = name self.facets = {} self end
Public Instance Methods
this method adds a facet to the facet group
-
Args :
-
facet
-> instance ofAboutYou::SDK::Model::Facet
which should be added
-
# File lib/AboutYou/Model/facet_group.rb, line 41 def add_facet(facet) facets[facet.id] = facet end
this method adds facets to the facet group
-
Args :
-
facets
-> Array containing instances ofAboutYou::SDK::Model::Facet
which should be added
-
# File lib/AboutYou/Model/facet_group.rb, line 51 def add_facets(facets) facets.each do |facet| add_facet(facet) end end
This method checks if this facet group contains a facet
-
Args :
-
facet
-> instance ofAboutYou::SDK::Model::Facet
-
-
Returns :
-
Boolean determining whether this facet group contains the facet or not
-
# File lib/AboutYou/Model/facet_group.rb, line 124 def contains(facet) facets.key?(facet.id) end
This method is used for checking whether a given facet group is equal to this facet group
-
Args :
-
facet_group
-> instance ofAboutYou::SDK::Model::FacetGroup
used for checking
-
-
Returns : -Boolean determining whether the facet groups are equal
# 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
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
-
# 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
Gett for the ids
-
Returns :
-
Hash containing a pair of facet_group_id => Array of facet_ids
-
# File lib/AboutYou/Model/facet_group.rb, line 111 def ids { id => facets.keys } end
This method is used for creating a unique key for this facet group
-
Returns :
-
a String containing a unique key for this facet group
-
# 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