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.
-
#stage ⇒ Object
Returns the value of attribute stage.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(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(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 |
# 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
#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 |
#stage ⇒ Object
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_iteration ⇒ Object
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_stage ⇒ Object
22 23 24 |
# File 'lib/pubid/iso/supplement.rb', line 22 def render_pubid_stage ((@stage && @stage.abbr != "IS" && @stage.abbr) || "") end |
#render_urn_number ⇒ Object
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_stage ⇒ Object
26 27 28 |
# File 'lib/pubid/iso/supplement.rb', line 26 def render_urn_stage ((@stage && ":stage-#{@stage.harmonized_code}") || "") end |