Class: Pubid::Iso::Supplement
- Inherits:
-
Core::Supplement
- Object
- Core::Supplement
- Pubid::Iso::Supplement
- Defined in:
- lib/pubid/iso/supplement.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#edition ⇒ Object
Returns the value of attribute edition.
-
#iteration ⇒ Object
Returns the value of attribute iteration.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#typed_stage ⇒ Object
Returns the value of attribute typed_stage.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(typed_stage: nil, publisher: nil, edition: nil, iteration: nil, **args) ⇒ Supplement
constructor
A new instance of Supplement.
- #render_iteration ⇒ Object
- #render_pubid_number(with_date: true) ⇒ Object
- #render_pubid_stage ⇒ Object
- #render_urn_number ⇒ Object
- #render_urn_stage ⇒ Object
Constructor Details
#initialize(typed_stage: nil, publisher: nil, edition: nil, iteration: nil, **args) ⇒ Supplement
Returns a new instance of Supplement.
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
#edition ⇒ Object
Returns the value of attribute edition.
3 4 5 |
# File 'lib/pubid/iso/supplement.rb', line 3 def edition @edition end |
#iteration ⇒ Object
Returns the value of attribute iteration.
3 4 5 |
# File 'lib/pubid/iso/supplement.rb', line 3 def iteration @iteration end |
#publisher ⇒ Object
Returns the value of attribute publisher.
3 4 5 |
# File 'lib/pubid/iso/supplement.rb', line 3 def publisher @publisher end |
#typed_stage ⇒ Object
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_iteration ⇒ Object
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_stage ⇒ Object
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_number ⇒ Object
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_stage ⇒ Object
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 |