Class: RelatonIeee::PubId::Id

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_ieee/pub_id.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number:, **args) ⇒ Id

PubId constructor

Parameters:

  • number (String)
  • **args (<Hash>)
  • args (Hash)

    a customizable set of options

Options Hash (**args):

  • :number (String)
  • :publisher (String)
  • :stage (String)
  • :part (String)
  • :status (String)
  • :approval (String)
  • :edition (String)
  • :draft (String)
  • :rev (String)
  • :corr (String)
  • :amd (String)
  • :redline (Boolean)
  • :year (String)
  • :month (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/relaton_ieee/pub_id.rb', line 31

def initialize(number:, **args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  @publisher = args[:publisher]
  @stage = args[:stage]
  @number = number
  @part = args[:part]
  @status = args[:status]
  @approval = args[:approval]
  @edition = args[:edition]
  @draft = args[:draft]
  @rev = args[:rev]
  @corr = args[:corr]
  @amd = args[:amd]
  @year = args[:year]
  @month = args[:month]
  @redline = args[:redline]
end

Instance Attribute Details

#amdString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def amd
  @amd
end

#approvalString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def approval
  @approval
end

#corrString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def corr
  @corr
end

#draftString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def draft
  @draft
end

#editionString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def edition
  @edition
end

#monthString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def month
  @month
end

#numberString (readonly)

Returns:

  • (String)


5
6
7
# File 'lib/relaton_ieee/pub_id.rb', line 5

def number
  @number
end

#partString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def part
  @part
end

#publisherString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def publisher
  @publisher
end

#redlineString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def redline
  @redline
end

#revString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def rev
  @rev
end

#stageString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def stage
  @stage
end

#statusString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def status
  @status
end

#yearString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton_ieee/pub_id.rb', line 8

def year
  @year
end

Instance Method Details

#amd_to_sObject



85
86
87
# File 'lib/relaton_ieee/pub_id.rb', line 85

def amd_to_s
  amd ? "/Amd#{amd}" : ""
end

#corr_to_sObject



81
82
83
# File 'lib/relaton_ieee/pub_id.rb', line 81

def corr_to_s
  corr ? "/Cor#{corr}" : ""
end

#draft_to_sObject



73
74
75
# File 'lib/relaton_ieee/pub_id.rb', line 73

def draft_to_s
  draft ? "/D-#{draft}" : ""
end

#edition_to_sObject



69
70
71
# File 'lib/relaton_ieee/pub_id.rb', line 69

def edition_to_s
  edition ? "/E-#{edition}" : ""
end

#month_to_sObject



93
94
95
# File 'lib/relaton_ieee/pub_id.rb', line 93

def month_to_s
  month ? "-#{month}" : ""
end

#redline_to_sObject



97
98
99
# File 'lib/relaton_ieee/pub_id.rb', line 97

def redline_to_s
  redline ? " Redline" : ""
end

#rev_to_sObject



77
78
79
# File 'lib/relaton_ieee/pub_id.rb', line 77

def rev_to_s
  rev ? "/R-#{rev}" : ""
end

#to_s(trademark: false) ⇒ String

PubId string representation

Parameters:

  • trademark (Boolean) (defaults to: false)

    if true, add trademark symbol

Returns:

  • (String)


55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/relaton_ieee/pub_id.rb', line 55

def to_s(trademark: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  out = number
  out = "#{stage} #{out}" if stage
  out = "#{approval} #{out}" if approval
  out = "#{status} #{out}" if status
  out = "#{publisher} #{out}" if publisher
  out += ".#{part}" if part
  if trademark
    out += out.match?(/^IEEE\s(Std\s)?(802|2030)/) ? "\u00AE" : "\u2122"
  end
  out += edition_to_s + draft_to_s + rev_to_s + corr_to_s + amd_to_s
  out + year_to_s + month_to_s + redline_to_s
end

#year_to_sObject



89
90
91
# File 'lib/relaton_ieee/pub_id.rb', line 89

def year_to_s
  year ? "-#{year}" : ""
end