Class: RelatonCalconnect::Processor

Inherits:
Relaton::Processor
  • Object
show all
Defined in:
lib/relaton_calconnect/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcessor

rubocop:disable Lint/MissingSuper



7
8
9
10
11
12
13
# File 'lib/relaton_calconnect/processor.rb', line 7

def initialize # rubocop:disable Lint/MissingSuper
  @short = :relaton_calconnect
  @prefix = "CC"
  @defaultprefix = %r{^CC(?!\w)}
  @idtype = "CC"
  @datasets = %w[calconnect-org]
end

Instance Attribute Details

#idtypeObject (readonly)

Returns the value of attribute idtype.



5
6
7
# File 'lib/relaton_calconnect/processor.rb', line 5

def idtype
  @idtype
end

Instance Method Details

#fetch_data(_source, opts) ⇒ Object

Fetch all the documents from a source

Parameters:

  • _source (String)

    source name

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents

  • :format (String)


31
32
33
# File 'lib/relaton_calconnect/processor.rb', line 31

def fetch_data(_source, opts)
  DataFetcher.fetch(**opts)
end

#from_xml(xml) ⇒ RelatonCalconnect::CcBibliographicItem

Parameters:

  • xml (String)

Returns:



37
38
39
# File 'lib/relaton_calconnect/processor.rb', line 37

def from_xml(xml)
  ::RelatonCalconnect::XMLParser.from_xml xml
end

#get(code, date, opts) ⇒ RelatonCalconnect::CcBibliographicItem

Parameters:

  • code (String)
  • date (String, NilClass)

    year

  • opts (Hash)

Returns:



19
20
21
# File 'lib/relaton_calconnect/processor.rb', line 19

def get(code, date, opts)
  ::RelatonCalconnect::CcBibliography.get(code, date, opts)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


49
50
51
# File 'lib/relaton_calconnect/processor.rb', line 49

def grammar_hash
  @grammar_hash ||= ::RelatonCalconnect.grammar_hash
end

#hash_to_bib(hash) ⇒ RelatonIsoBib::CcBibliographicItem

Parameters:

  • hash (Hash)

Returns:

  • (RelatonIsoBib::CcBibliographicItem)


43
44
45
# File 'lib/relaton_calconnect/processor.rb', line 43

def hash_to_bib(hash)
  ::RelatonCalconnect::CcBibliographicItem.from_hash hash
end

#remove_index_fileObject

Remove index file



56
57
58
# File 'lib/relaton_calconnect/processor.rb', line 56

def remove_index_file
  Relaton::Index.find_or_create(:CC, url: true, file: HitCollection::INDEX_FILE).remove_file
end