Class: Esearch::Presenter::Facet

Inherits:
Esearch::Presenter show all
Defined in:
lib/esearch/presenter/facet.rb

Overview

Base class for facets in results

Direct Known Subclasses

Range, Terms

Defined Under Namespace

Classes: Range, Terms

Constant Summary collapse

TYPE_KEY =
'_type'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(raw) ⇒ Facet

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build facet from raw

Parameters:

  • raw (Hash)

Returns:



19
20
21
22
# File 'lib/esearch/presenter/facet.rb', line 19

def self.build(raw)
  type = raw.fetch(TYPE_KEY)
  get(type).new(raw)
end

Instance Method Details

#aspectsEnumerable<Aspect>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enumerate aspects

Returns:



45
46
47
48
# File 'lib/esearch/presenter/facet.rb', line 45

def aspects
  util = self.class
  raw.fetch(util::FACET_KEY).map(&util::ASPECT_CLASS.method(:new))
end