Class: RelatonBsi::HitCollection

Inherits:
RelatonBib::HitCollection
  • Object
show all
Defined in:
lib/relaton_bsi/hit_collection.rb

Overview

Page of hit collection.

Constant Summary collapse

DOMAIN =
"https://shop.bsigroup.com"

Instance Method Summary collapse

Constructor Details

#initialize(reference, year = nil) ⇒ HitCollection

Initialize a new HitCollection.

Parameters:

  • reference (String)

    reference

  • year (String) (defaults to: nil)

    year



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/relaton_bsi/hit_collection.rb', line 17

def initialize(reference, year = nil)
  super reference, year
  config = Algolia::Search::Config.new(
    application_id: "575YE157G9",
    api_key: "a057b4e74099445df2eddb7940828a10",
  )
  client = Algolia::Search::Client.new config, logger: ::Logger.new($stderr)
  index = client.init_index "shopify_products"
  ref = text.sub(/ExComm|Expert commentary/, "Ex")
  resp = index.search ref # , facetFilters: "product_type:standard"
  @array = create_hits resp[:hits]
end

Instance Method Details

#filter_hits!(code_parts) ⇒ self

Filter the search results for a BSI standard.

Parameters:

  • code_parts (MatchData)

    parts of document identifier

Returns:

  • (self)

    filtered search results



37
38
39
40
41
42
43
# File 'lib/relaton_bsi/hit_collection.rb', line 37

def filter_hits!(code_parts)
  hits = filter code_parts
  hits = filter code_parts, skip_rest: true if hits.empty?
  hits = filter code_parts, drop_amd: true if hits.empty?
  @array = hits
  self
end