Class: Relaton::Itu::Processor

Inherits:
Core::Processor
  • Object
show all
Defined in:
lib/relaton/itu/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/itu/processor.rb', line 6

def initialize
  @short = :relaton_itu
  @prefix = "ITU"
  @defaultprefix = %r{^ITU\s}
  @idtype = "ITU"
  @datasets = %w[itu-r]
end

Instance Method Details

#fetch_data(source, opts) ⇒ Object

Fetch all the documents from extranet.itu.int/brdocsearch/

Parameters:

  • source (String)

    source name (itu-r)

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents, default is data

  • :format (String)

    output format, default is yaml



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

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

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

Parameters:

  • xml (String)

Returns:



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

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

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

Parameters:

  • yaml (Hash)

Returns:



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

def from_yaml(yaml)
  require_relative "../itu"
  Item.from_yaml yaml
end

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

Parameters:

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

    year

  • opts (Hash)

Returns:



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

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

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


52
53
54
55
# File 'lib/relaton/itu/processor.rb', line 52

def grammar_hash
  require_relative "../itu"
  @grammar_hash ||= Itu.grammar_hash
end

#remove_index_fileObject

Remove index file



60
61
62
63
# File 'lib/relaton/itu/processor.rb', line 60

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