Class: RelatonEtsi::DataParser
- Inherits:
-
Object
- Object
- RelatonEtsi::DataParser
- Defined in:
- lib/relaton_etsi/data_parser.rb
Constant Summary collapse
- ATTRS =
%i[id title docnumber link date docid version status contributor keyword editorialgroup doctype abstract language script].freeze
Instance Method Summary collapse
- #abstract ⇒ Object
- #contributor ⇒ Object
- #date ⇒ Object
- #docid ⇒ Object
- #docnumber ⇒ Object
- #doctype ⇒ Object
- #editorialgroup ⇒ Object
- #id ⇒ Object
-
#initialize(row) ⇒ DataParser
constructor
A new instance of DataParser.
- #keyword ⇒ Object
- #language ⇒ Object
- #link ⇒ Object
- #parse ⇒ Object
- #pubid ⇒ Object
- #script ⇒ Object
- #status ⇒ Object
- #title ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(row) ⇒ DataParser
Returns a new instance of DataParser.
6 7 8 |
# File 'lib/relaton_etsi/data_parser.rb', line 6 def initialize(row) @row = row end |
Instance Method Details
#abstract ⇒ Object
83 84 85 86 87 |
# File 'lib/relaton_etsi/data_parser.rb', line 83 def abstract return [] unless @row["Scope"] [RelatonBib::FormattedString.new(content: @row["Scope"], language: "en", script: "Latn")] end |
#contributor ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/relaton_etsi/data_parser.rb', line 60 def contributor name = RelatonBib::LocalizedString.new( "European Telecommunications Standards Institute", "en", "Latn" ) abbrev = RelatonBib::LocalizedString.new("ETSI", "en", "Latn") entity = RelatonBib::Organization.new name: [name], abbreviation: abbrev [RelatonBib::ContributionInfo.new(entity: entity, role: [{ type: "publisher" }])] end |
#date ⇒ Object
39 40 41 42 43 |
# File 'lib/relaton_etsi/data_parser.rb', line 39 def date return [] unless pubid.date [RelatonBib::BibliographicDate.new(type: "published", on: pubid.date)] end |
#docid ⇒ Object
45 46 47 |
# File 'lib/relaton_etsi/data_parser.rb', line 45 def docid [RelatonBib::DocumentIdentifier.new(id: @row["ETSI deliverable"], type: "ETSI", primary: true)] end |
#docnumber ⇒ Object
29 30 31 |
# File 'lib/relaton_etsi/data_parser.rb', line 29 def docnumber @row["ETSI deliverable"] end |
#doctype ⇒ Object
79 80 81 |
# File 'lib/relaton_etsi/data_parser.rb', line 79 def doctype DocumentType.create_from_abbreviation pubid.type end |
#editorialgroup ⇒ Object
73 74 75 76 77 |
# File 'lib/relaton_etsi/data_parser.rb', line 73 def editorialgroup wg = RelatonBib::WorkGroup.new name: @row["Technical body"] tc = RelatonBib::TechnicalCommittee.new wg RelatonBib::EditorialGroup.new [tc] end |
#id ⇒ Object
21 22 23 |
# File 'lib/relaton_etsi/data_parser.rb', line 21 def id @row["ETSI deliverable"].gsub(/[\s\(\)]/, "") end |
#keyword ⇒ Object
69 70 71 |
# File 'lib/relaton_etsi/data_parser.rb', line 69 def keyword @row["Keywords"].split(",") end |
#language ⇒ Object
89 90 91 |
# File 'lib/relaton_etsi/data_parser.rb', line 89 def language ["en"] end |
#link ⇒ Object
33 34 35 36 37 |
# File 'lib/relaton_etsi/data_parser.rb', line 33 def link urls = [] urls << RelatonBib::TypedUri.new(content: @row["Details link"], type: "src") urls << RelatonBib::TypedUri.new(content: @row["PDF link"], type: "pdf") end |
#parse ⇒ Object
10 11 12 13 14 15 |
# File 'lib/relaton_etsi/data_parser.rb', line 10 def parse args = ATTRS.each_with_object({}) do |attr, hash| hash[attr] = send(attr) end BibliographicItem.new(**args) end |
#pubid ⇒ Object
17 18 19 |
# File 'lib/relaton_etsi/data_parser.rb', line 17 def pubid @pubid ||= PubId.parse(@row["ETSI deliverable"]) end |
#script ⇒ Object
93 94 95 |
# File 'lib/relaton_etsi/data_parser.rb', line 93 def script ["Latn"] end |
#status ⇒ Object
55 56 57 58 |
# File 'lib/relaton_etsi/data_parser.rb', line 55 def status status = @row["Status"] == "On Approval" ? "#{pubid.type} approval" : @row["Status"] RelatonBib::DocumentStatus.new(stage: status) end |
#title ⇒ Object
25 26 27 |
# File 'lib/relaton_etsi/data_parser.rb', line 25 def title [RelatonBib::TypedTitleString.new(content: @row["title"], language: "en", script: "Latn")] end |
#version ⇒ Object
49 50 51 52 53 |
# File 'lib/relaton_etsi/data_parser.rb', line 49 def version return [] unless pubid.version [RelatonBib::BibliographicItem::Version.new(nil, pubid.version)] end |