Class: Relaton::Index::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton/index/pool.rb

Overview

Pool of indexes

Instance Method Summary collapse

Constructor Details

#initializePool

Returns a new instance of Pool.



7
8
9
# File 'lib/relaton/index/pool.rb', line 7

def initialize
  @pool = {}
end

Instance Method Details

#remove(type) ⇒ void

This method returns an undefined value.

Remove index by type from pool

Parameters:

  • type (String)

    index type



36
37
38
# File 'lib/relaton/index/pool.rb', line 36

def remove(type)
  @pool.delete type.upcase.to_sym
end

#type(type, **args) ⇒ Relaton::Index::Type

Return index by type, create if not exists

Parameters:

  • type (String)

    <description>

  • url (String, nil)

    external URL to index, used to fetch index for searching files

  • file (String, nil)

    output file name

  • id_keys (Array<Symbol>, nil)

    keys to check if index is correct

Returns:



21
22
23
24
25
26
27
# File 'lib/relaton/index/pool.rb', line 21

def type(type, **args)
  if @pool[type.upcase.to_sym]&.actual?(**args)
    @pool[type.upcase.to_sym]
  else
    @pool[type.upcase.to_sym] = Type.new(type, args[:url], args[:file], args[:id_keys], args[:pubid_class])
  end
end