Class: RelatonIec::Processor

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

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.



5
6
7
8
9
10
11
# File 'lib/relaton_iec/processor.rb', line 5

def initialize
  @short = :relaton_iec
  @prefix = "IEC"
  @defaultprefix = %r{^(IEC\s|CISPR\s|IEV($|\s))}
  @idtype = "IEC"
  @datasets = %w[iec-harmonized-all iec-harmonized-latest]
end

Instance Method Details

#fetch_data(source, opts) ⇒ Object

Fetch all the documents from a source

Parameters:

  • source (String)

    source name (iec-harmonized-all, iec-harmonized-latest)

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents

  • :format (String)

    output format (xml, yaml, bibxml)



29
30
31
# File 'lib/relaton_iec/processor.rb', line 29

def fetch_data(source, opts)
  DataFetcher.new(source, **opts).fetch
end

#from_xml(xml) ⇒ RelatonIsoBib::IecBibliographicItem

Parameters:

  • xml (String)

Returns:

  • (RelatonIsoBib::IecBibliographicItem)


35
36
37
# File 'lib/relaton_iec/processor.rb', line 35

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

#get(code, date, opts) ⇒ RelatonIsoBib::IecBibliographicItem

Parameters:

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

    year

  • opts (Hash)

Returns:

  • (RelatonIsoBib::IecBibliographicItem)


17
18
19
# File 'lib/relaton_iec/processor.rb', line 17

def get(code, date, opts)
  ::RelatonIec::IecBibliography.get(code, date, opts)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


47
48
49
# File 'lib/relaton_iec/processor.rb', line 47

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

#hash_to_bib(hash) ⇒ RelatonIec::IecBibliographicItem

Parameters:

  • hash (Hash)

Returns:



41
42
43
# File 'lib/relaton_iec/processor.rb', line 41

def hash_to_bib(hash)
  ::RelatonIec::IecBibliographicItem.from_hash hash
end

#remove_index_fileObject

Remove index file



60
61
62
# File 'lib/relaton_iec/processor.rb', line 60

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

#urn_to_code(code) ⇒ String?

Parameters:

  • code (String)

Returns:

  • (String, nil)


53
54
55
# File 'lib/relaton_iec/processor.rb', line 53

def urn_to_code(code)
  RelatonIec.urn_to_code code
end