Class: Relaton::Ecma::Processor

Inherits:
Core::Processor
  • Object
show all
Defined in:
lib/relaton/ecma/processor.rb

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.



6
7
8
9
10
11
12
# File 'lib/relaton/ecma/processor.rb', line 6

def initialize
  @short = :relaton_ecma
  @prefix = "ECMA"
  @defaultprefix = /^ECMA(-|\s)/
  @idtype = "ECMA"
  @datasets = %w[ecma-standards]
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)



31
32
33
34
# File 'lib/relaton/ecma/processor.rb', line 31

def fetch_data(source, opts)
  require_relative "data_fetcher"
  DataFetcher.fetch(source, **opts)
end

#from_xml(xml) ⇒ Relaton::Ecma::ItemData

Parameters:

  • xml (String)

Returns:



38
39
40
41
# File 'lib/relaton/ecma/processor.rb', line 38

def from_xml(xml)
  require_relative "../ecma"
  Item.from_xml xml
end

#from_yaml(yaml) ⇒ Relaton::Ecma::ItemData

Parameters:

  • yaml (String)

Returns:



45
46
47
# File 'lib/relaton/ecma/processor.rb', line 45

def from_yaml(yaml)
  Item.from_yaml yaml
end

#get(code, date, opts) ⇒ Relaton::Ecma::ItemData?

Parameters:

  • code (String)
  • date (String, nil)

    year

  • opts (Hash)

Returns:



18
19
20
21
# File 'lib/relaton/ecma/processor.rb', line 18

def get(code, date, opts)
  require_relative "../ecma"
  Bibliography.get(code, date, opts)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


51
52
53
54
# File 'lib/relaton/ecma/processor.rb', line 51

def grammar_hash
  require_relative "../ecma"
  @grammar_hash ||= Ecma.grammar_hash
end

#remove_index_fileObject

Remove index file



59
60
61
62
# File 'lib/relaton/ecma/processor.rb', line 59

def remove_index_file
  require_relative "../ecma"
  Relaton::Index.find_or_create(:ECMA, url: true, file: "#{INDEXFILE}.yaml").remove_file
end