Class: Metanorma::Release::DocumentVersion
- Inherits:
-
Object
- Object
- Metanorma::Release::DocumentVersion
- Defined in:
- lib/metanorma/release/document_version.rb
Instance Attribute Summary collapse
-
#edition ⇒ Object
readonly
Returns the value of attribute edition.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #file_name(doc_id) ⇒ Object
- #hash ⇒ Object
-
#initialize(edition:, stage:) ⇒ DocumentVersion
constructor
A new instance of DocumentVersion.
- #pre_release? ⇒ Boolean
- #tag_component ⇒ Object
Constructor Details
#initialize(edition:, stage:) ⇒ DocumentVersion
Returns a new instance of DocumentVersion.
18 19 20 21 22 |
# File 'lib/metanorma/release/document_version.rb', line 18 def initialize(edition:, stage:) @edition = edition @stage = stage freeze end |
Instance Attribute Details
#edition ⇒ Object (readonly)
Returns the value of attribute edition.
6 7 8 |
# File 'lib/metanorma/release/document_version.rb', line 6 def edition @edition end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
6 7 8 |
# File 'lib/metanorma/release/document_version.rb', line 6 def stage @stage end |
Class Method Details
.from(edition, stage) ⇒ Object
8 9 10 11 12 |
# File 'lib/metanorma/release/document_version.rb', line 8 def self.from(edition, stage) ed = edition.to_s.strip ed = '0' if ed.empty? new(edition: ed, stage: stage) end |
.published(edition:) ⇒ Object
14 15 16 |
# File 'lib/metanorma/release/document_version.rb', line 14 def self.published(edition:) new(edition: edition.to_s.strip, stage: DocumentStage.published) end |
Instance Method Details
#eql?(other) ⇒ Boolean
41 42 43 |
# File 'lib/metanorma/release/document_version.rb', line 41 def eql?(other) other.is_a?(self.class) && edition == other.edition && stage.eql?(other.stage) end |
#file_name(doc_id) ⇒ Object
36 37 38 39 |
# File 'lib/metanorma/release/document_version.rb', line 36 def file_name(doc_id) base = "#{doc_id}-#{tag_component}" "#{base}.zip" end |
#hash ⇒ Object
45 46 47 |
# File 'lib/metanorma/release/document_version.rb', line 45 def hash [edition, stage].hash end |
#pre_release? ⇒ Boolean
32 33 34 |
# File 'lib/metanorma/release/document_version.rb', line 32 def pre_release? stage.draft? end |
#tag_component ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/metanorma/release/document_version.rb', line 24 def tag_component base = "ed#{edition}" return base if stage.published? suffix = stage.tag_suffix suffix.empty? ? base : "#{base}-#{suffix}" end |