Class: Relaton::Bipm::DataFetcher
- Inherits:
-
Core::DataFetcher
- Object
- Core::DataFetcher
- Relaton::Bipm::DataFetcher
- Defined in:
- lib/relaton/bipm/data_fetcher.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#fetch(source) ⇒ Object
Fetch bipm-data-outcomes or si-brochure.
- #log_error(msg) ⇒ Object
- #to_bibxml(item) ⇒ Object
- #to_xml(item) ⇒ Object
- #to_yaml(item) ⇒ Object
-
#write_file(path, item, warn_duplicate: true) ⇒ Object
Save document to file.
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 9 def errors @errors end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
9 10 11 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 9 def ext @ext end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
9 10 11 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 9 def files @files end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
9 10 11 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 9 def format @format end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
9 10 11 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 9 def index @index end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
9 10 11 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 9 def output @output end |
Instance Method Details
#fetch(source) ⇒ Object
Fetch bipm-data-outcomes or si-brochure
24 25 26 27 28 29 30 31 32 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 24 def fetch(source) case source when "bipm-data-outcomes" then DataOutcomesParser.parse(self) when "bipm-si-brochure" then SiBrochureParser.parse(self) when "rawdata-bipm-metrologia" then RawdataBipmMetrologia::Fetcher.fetch(self) end index.save report_errors end |
#log_error(msg) ⇒ Object
15 16 17 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 15 def log_error(msg) Util.error msg end |
#to_bibxml(item) ⇒ Object
55 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 55 def to_bibxml(item) = item.to_rfcxml |
#to_xml(item) ⇒ Object
51 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 51 def to_xml(item) = item.to_xml bibdata: true |
#to_yaml(item) ⇒ Object
53 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 53 def to_yaml(item) = item.to_yaml |
#write_file(path, item, warn_duplicate: true) ⇒ Object
Save document to file
41 42 43 44 45 46 47 48 49 |
# File 'lib/relaton/bipm/data_fetcher.rb', line 41 def write_file(path, item, warn_duplicate: true) content = serialize item if @files.include?(path) Util.warn "File #{path} already exists" if warn_duplicate else @files << path end File.write path, content, encoding: "UTF-8" end |