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(typed_stage: nil, publisher: nil, edition: nil, iteration: nil, **args) ⇒ Supplement

Returns a new instance of Supplement.

Parameters:

  • stage (Stage, Symbol, String)

    stage, e.g. “PWI”, “NP”, “50.00”, Stage.new(abbr: :WD)

  • publisher (String) (defaults to: nil)

    publisher, e.g. “ISO”, “IEC” (only for DIR documents)

  • 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
21
# File 'lib/pubid/iso/supplement.rb', line 10

def initialize(typed_stage: nil, publisher: nil, edition: nil, iteration: nil, **args)
  super(**args)
  @typed_stage = TypedStage.parse(typed_stage) if typed_stage
  # for DIR identifiers only
  @publisher = publisher.to_s
  @edition = edition&.to_i
  @iteration = iteration&.to_i

  if @iteration && @typed_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

#typed_stageObject

Returns the value of attribute typed_stage.



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

def typed_stage
  @typed_stage
end

Instance Method Details

#<=>(other) ⇒ Object



32
33
34
# File 'lib/pubid/iso/supplement.rb', line 32

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

#render_iterationObject



36
37
38
# File 'lib/pubid/iso/supplement.rb', line 36

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

#render_pubid_number(with_date: true) ⇒ Object



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

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

#render_pubid_stageObject



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

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

#render_urn_numberObject



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

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

#render_urn_stageObject



28
29
30
# File 'lib/pubid/iso/supplement.rb', line 28

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