Class: Ieee::Idams::PubModel
- Inherits:
-
Object
- Object
- Ieee::Idams::PubModel
- Defined in:
- lib/ieee/idams/pub_model.rb
Overview
Represents an IEEE IDAMS publication record
Constant Summary collapse
- DATETYPES =
{ "OriginalPub" => "created", "ePub" => "published", "LastInspecUpd" => "updated" }.freeze
Instance Attribute Summary collapse
-
#normtitle ⇒ Object
Returns the value of attribute normtitle.
-
#publicationinfo ⇒ Object
Returns the value of attribute publicationinfo.
-
#standardsfamilytitle ⇒ Object
Returns the value of attribute standardsfamilytitle.
-
#title ⇒ Object
Returns the value of attribute title.
-
#volume ⇒ Object
Returns the value of attribute volume.
Instance Method Summary collapse
-
#bdate ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength.
- #btitle ⇒ Object
-
#contrib_name_addr ⇒ Array<String, Array>
Publisher name and address.
-
#copyright ⇒ Array<Array, Object>
Array of arrays with owner and year of given block result.
- #docstatus ⇒ Object
- #doctype ⇒ Object
- #editorialgroup ⇒ Object
- #ics ⇒ Object
-
#isbn_doi ⇒ Arry<Hash>
Array of hashes with keys :id and :type.
- #keyword ⇒ Object
- #link ⇒ Object
- #standard_modifier ⇒ Object
Instance Attribute Details
#normtitle ⇒ Object
Returns the value of attribute normtitle.
9 10 11 |
# File 'lib/ieee/idams/pub_model.rb', line 9 def normtitle @normtitle end |
#publicationinfo ⇒ Object
Returns the value of attribute publicationinfo.
9 10 11 |
# File 'lib/ieee/idams/pub_model.rb', line 9 def publicationinfo @publicationinfo end |
#standardsfamilytitle ⇒ Object
Returns the value of attribute standardsfamilytitle.
9 10 11 |
# File 'lib/ieee/idams/pub_model.rb', line 9 def standardsfamilytitle @standardsfamilytitle end |
#title ⇒ Object
Returns the value of attribute title.
9 10 11 |
# File 'lib/ieee/idams/pub_model.rb', line 9 def title @title end |
#volume ⇒ Object
Returns the value of attribute volume.
9 10 11 |
# File 'lib/ieee/idams/pub_model.rb', line 9 def volume @volume end |
Instance Method Details
#bdate ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ieee/idams/pub_model.rb', line 18 def bdate # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength dates = volume.article.articleinfo.date.map do |d| date_array = [d.year] if d.month /^(?:(?<day>\d{1,2})\s)?(?<mon>\w+)/ =~ d.month month = Date::ABBR_MONTHNAMES.index(mon) || Date::MONTHNAMES.index(mon) || d.month date_array << month.to_s.rjust(2, "0") end day = d.day || day date_array << day.rjust(2, "0") if day on = date_array.compact.join "-" { type: DATETYPES[d.datetype], on: on } end if publicationinfo.pubapprovaldate issued = parse_date_string publicationinfo.pubapprovaldate dates << { type: "issued", on: issued } end dates end |
#btitle ⇒ Object
11 12 13 14 15 16 |
# File 'lib/ieee/idams/pub_model.rb', line 11 def btitle t = [] content = CGI.unescapeHTML volume.article.title t << { content: Regexp.last_match(1), type: "title-main" } if content =~ /\A(.+)\s[-\u2014]\sredline\z/i t << { content: content, type: "main" } end |
#contrib_name_addr ⇒ Array<String, Array>
Returns publisher name and address.
53 54 55 56 |
# File 'lib/ieee/idams/pub_model.rb', line 53 def contrib_name_addr addr = contrib_addres(publicationinfo.publisher.address).map { |a| block_given? ? yield(a) : a } [publicationinfo.publisher.publishername, addr] end |
#copyright ⇒ Array<Array, Object>
Returns array of arrays with owner and year of given block result.
61 62 63 64 65 66 67 |
# File 'lib/ieee/idams/pub_model.rb', line 61 def copyright publicationinfo.copyrightgroup.copyright.map do |copy| owner = copy.holder.split("/") year = copy.year.to_s block_given? ? yield(owner, year) : [owner, year] end end |
#docstatus ⇒ Object
69 70 71 72 73 74 |
# File 'lib/ieee/idams/pub_model.rb', line 69 def docstatus return unless %w[Draft Approved Superseded Withdrawn].include?(standard_modifier) args = { stage: standard_modifier.downcase } block_given? ? yield(args) : args end |
#doctype ⇒ Object
108 109 110 |
# File 'lib/ieee/idams/pub_model.rb', line 108 def doctype standard_modifier == "Redline" ? "redline" : "standard" end |
#editorialgroup ⇒ Object
97 98 99 100 101 102 |
# File 'lib/ieee/idams/pub_model.rb', line 97 def editorialgroup committee = publicationinfo.pubsponsoringcommitteeset&.pubsponsoringcommittee return unless committee block_given? ? yield(committee) : committee end |
#ics ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/ieee/idams/pub_model.rb', line 88 def ics return [] unless publicationinfo.ics_codes publicationinfo.ics_codes.code_term.map do |ics| attrs = { code: ics.codenum, text: ics.name } block_given? ? yield(attrs) : attrs end end |
#isbn_doi ⇒ Arry<Hash>
Returns array of hashes with keys :id and :type.
41 42 43 44 45 46 47 48 |
# File 'lib/ieee/idams/pub_model.rb', line 41 def isbn_doi ids = [] isbn = publicationinfo.isbn ids << { id: isbn.first.content, type: "ISBN" } if isbn.any? doi = volume.article.articleinfo.articledoi ids << { id: doi, type: "DOI" } if doi ids end |
#keyword ⇒ Object
82 83 84 85 86 |
# File 'lib/ieee/idams/pub_model.rb', line 82 def keyword volume.article.articleinfo.keywordset.inject([]) do |acc, keywordset| acc + keywordset.keyword.map(&:keywordterm) end.uniq end |
#link ⇒ Object
76 77 78 79 80 |
# File 'lib/ieee/idams/pub_model.rb', line 76 def link id = volume.article.articleinfo.amsid url = "https://ieeexplore.ieee.org/document/#{id}" [block_given? ? yield(url) : url] end |
#standard_modifier ⇒ Object
104 105 106 |
# File 'lib/ieee/idams/pub_model.rb', line 104 def standard_modifier publicationinfo.standard_modifier_set&.standard_modifier end |