Class: Pubid::Iso::Supplement

Inherits:
Core::Supplement
  • Object
show all
Defined in:
lib/pubid/iso/supplement.rb

Direct Known Subclasses

Amendment, Corrigendum

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage: nil, publisher: nil, edition: nil, iteration: nil, **args) ⇒ Supplement

Returns a new instance of Supplement.

Parameters:

  • stage (Stage) (defaults to: nil)

    stage, e.g. “PWI”, “NP”

  • publisher (String) (defaults to: nil)

    publisher, e.g. “ISO”, “IEC”

  • edition (Integer) (defaults to: nil)

    edition, e.g. 1, 2, 3

  • iteration (Integer) (defaults to: nil)

    iteration, e.g. 1, 2, 3

See Also:

  • for other options


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pubid/iso/supplement.rb', line 10

def initialize(stage: nil, publisher: nil, edition: nil, iteration: nil, **args)
  super(**args)
  @stage = (stage.is_a?(Symbol) || stage.is_a?(String)) ? Stage.new(abbr: stage) : stage
  @publisher = publisher.to_s
  @edition = edition&.to_i
  @iteration = iteration&.to_i

  if @iteration && @stage.nil?
    raise Errors::PublishedIterationError.new("cannot assign iteration to published supplement")
  end
end

Instance Attribute Details

#editionObject

Returns the value of attribute edition.



3
4
5
# File 'lib/pubid/iso/supplement.rb', line 3

def edition
  @edition
end

#iterationObject

Returns the value of attribute iteration.



3
4
5
# File 'lib/pubid/iso/supplement.rb', line 3

def iteration
  @iteration
end

#publisherObject

Returns the value of attribute publisher.



3
4
5
# File 'lib/pubid/iso/supplement.rb', line 3

def publisher
  @publisher
end

#stageObject

Returns the value of attribute stage.



3
4
5
# File 'lib/pubid/iso/supplement.rb', line 3

def stage
  @stage
end

Instance Method Details

#<=>(other) ⇒ Object



30
31
32
# File 'lib/pubid/iso/supplement.rb', line 30

def <=>(other)
  (super == 0) && ((stage.nil? || stage == other.stage) && 0 || -1) || super
end

#render_iterationObject



34
35
36
# File 'lib/pubid/iso/supplement.rb', line 34

def render_iteration
  @iteration && ".#{@iteration}"
end

#render_pubid_number(with_date: true) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/pubid/iso/supplement.rb', line 38

def render_pubid_number(with_date: true)
  if @year && with_date
    "#{@number}#{render_iteration}:#{@year}"
  else
    "#{@number}#{render_iteration}"
  end
end

#render_pubid_stageObject



22
23
24
# File 'lib/pubid/iso/supplement.rb', line 22

def render_pubid_stage
  ((@stage && @stage.abbr != "IS" && @stage.abbr) || "")
end

#render_urn_numberObject



46
47
48
49
50
51
52
# File 'lib/pubid/iso/supplement.rb', line 46

def render_urn_number
  if @year
    ":#{@year}:v#{@number}#{render_iteration}"
  else
    ":#{@number}#{render_iteration}:v1"
  end
end

#render_urn_stageObject



26
27
28
# File 'lib/pubid/iso/supplement.rb', line 26

def render_urn_stage
  ((@stage && ":stage-#{@stage.harmonized_code}") || "")
end