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.
10 11 12 |
# File 'lib/ieee/idams/pub_model.rb', line 10 def normtitle @normtitle end |
#publicationinfo ⇒ Object
Returns the value of attribute publicationinfo.
10 11 12 |
# File 'lib/ieee/idams/pub_model.rb', line 10 def publicationinfo @publicationinfo end |
#standardsfamilytitle ⇒ Object
Returns the value of attribute standardsfamilytitle.
10 11 12 |
# File 'lib/ieee/idams/pub_model.rb', line 10 def standardsfamilytitle @standardsfamilytitle end |
#title ⇒ Object
Returns the value of attribute title.
10 11 12 |
# File 'lib/ieee/idams/pub_model.rb', line 10 def title @title end |
#volume ⇒ Object
Returns the value of attribute volume.
10 11 12 |
# File 'lib/ieee/idams/pub_model.rb', line 10 def volume @volume end |
Instance Method Details
#bdate ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ieee/idams/pub_model.rb', line 23 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
13 14 15 16 17 18 19 20 21 |
# File 'lib/ieee/idams/pub_model.rb', line 13 def btitle t = [] content = CGI.unescapeHTML volume.article.title if content =~ /\A(.+)\s[-\u2014]\sredline\z/i t << { content: Regexp.last_match(1), type: "title-main" } end t << { content: content, type: "main" } end |
#contrib_name_addr ⇒ Array<String, Array>
Returns publisher name and address.
58 59 60 61 62 63 |
# File 'lib/ieee/idams/pub_model.rb', line 58 def contrib_name_addr addr = contrib_addres(publicationinfo.publisher.address).map do |a| block_given? ? yield(a) : a end [publicationinfo.publisher.publishername, addr] end |
#copyright ⇒ Array<Array, Object>
Returns array of arrays with owner and year of given block result.
68 69 70 71 72 73 74 |
# File 'lib/ieee/idams/pub_model.rb', line 68 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
76 77 78 79 80 81 82 |
# File 'lib/ieee/idams/pub_model.rb', line 76 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
116 117 118 |
# File 'lib/ieee/idams/pub_model.rb', line 116 def doctype standard_modifier == "Redline" ? "redline" : "standard" end |
#editorialgroup ⇒ Object
105 106 107 108 109 110 |
# File 'lib/ieee/idams/pub_model.rb', line 105 def editorialgroup committee = publicationinfo.pubsponsoringcommitteeset&.pubsponsoringcommittee return unless committee block_given? ? yield(committee) : committee end |
#ics ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/ieee/idams/pub_model.rb', line 96 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.
46 47 48 49 50 51 52 53 |
# File 'lib/ieee/idams/pub_model.rb', line 46 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
90 91 92 93 94 |
# File 'lib/ieee/idams/pub_model.rb', line 90 def keyword volume.article.articleinfo.keywordset.inject([]) do |acc, keywordset| acc + keywordset.keyword.map(&:keywordterm) end.uniq end |
#link ⇒ Object
84 85 86 87 88 |
# File 'lib/ieee/idams/pub_model.rb', line 84 def link id = volume.article.articleinfo.amsid url = "https://ieeexplore.ieee.org/document/#{id}" [block_given? ? yield(url) : url] end |
#standard_modifier ⇒ Object
112 113 114 |
# File 'lib/ieee/idams/pub_model.rb', line 112 def standard_modifier publicationinfo.standard_modifier_set&.standard_modifier end |