Class: Ieee::Idams::PubModel

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#normtitleObject

Returns the value of attribute normtitle.



9
10
11
# File 'lib/ieee/idams/pub_model.rb', line 9

def normtitle
  @normtitle
end

#publicationinfoObject

Returns the value of attribute publicationinfo.



9
10
11
# File 'lib/ieee/idams/pub_model.rb', line 9

def publicationinfo
  @publicationinfo
end

#standardsfamilytitleObject

Returns the value of attribute standardsfamilytitle.



9
10
11
# File 'lib/ieee/idams/pub_model.rb', line 9

def standardsfamilytitle
  @standardsfamilytitle
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/ieee/idams/pub_model.rb', line 9

def title
  @title
end

#volumeObject

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

#bdateObject

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..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

#btitleObject



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_addrArray<String, Array>

Returns publisher name and address.

Returns:

  • (Array<String, Array>)

    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

Returns array of arrays with owner and year of given block result.

Returns:

  • (Array<Array, Object>)

    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

#docstatusObject



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

#doctypeObject



108
109
110
# File 'lib/ieee/idams/pub_model.rb', line 108

def doctype
  standard_modifier == "Redline" ? "redline" : "standard"
end

#editorialgroupObject



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

#icsObject



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_doiArry<Hash>

Returns array of hashes with keys :id and :type.

Returns:

  • (Arry<Hash>)

    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..articledoi
  ids << { id: doi, type: "DOI" } if doi
  ids
end

#keywordObject



82
83
84
85
86
# File 'lib/ieee/idams/pub_model.rb', line 82

def keyword
  volume.article..keywordset.inject([]) do |acc, keywordset|
    acc + keywordset.keyword.map(&:keywordterm)
  end.uniq
end


76
77
78
79
80
# File 'lib/ieee/idams/pub_model.rb', line 76

def link
  id = volume.article..amsid
  url = "https://ieeexplore.ieee.org/document/#{id}"
  [block_given? ? yield(url) : url]
end

#standard_modifierObject



104
105
106
# File 'lib/ieee/idams/pub_model.rb', line 104

def standard_modifier
  publicationinfo.standard_modifier_set&.standard_modifier
end