class AboutYou::SDK::Model::FacetGroup

This class represents a facet group model

Attributes

facets[RW]

Array of instances of AboutYou::SDK::Model::Facet

group_id[RW]

id of the group of this facet group

id[RW]

id of this facet group

name[RW]

name of the facet group

Public Class Methods

new(id, name) click to toggle source

Constructor for the AboutYou::SDK::Model::FacetGroup class

# 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

add_facet(facet) click to toggle source

this method adds a facet to the facet group

# File lib/AboutYou/Model/facet_group.rb, line 41
def add_facet(facet)
  facets[facet.id] = facet
end
add_facets(facets) click to toggle source

this method adds facets to the facet group

# File lib/AboutYou/Model/facet_group.rb, line 51
def add_facets(facets)
  facets.each do |facet|
    add_facet(facet)
  end
end
contains(facet) click to toggle source

This method checks if this facet group contains a facet

  • Args :

  • 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
equal?(facet_group) click to toggle source

This method is used for checking whether a given facet group is equal to this facet group

# 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 = '/') click to toggle source

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
ids() click to toggle source

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
unique_key() click to toggle source

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