Class: RelatonBib::DocumentStatus
- Defined in:
- lib/relaton_bib/document_status.rb
Overview
Document status.
Defined Under Namespace
Classes: Stage
Instance Attribute Summary collapse
- #iteration ⇒ String, NilClass readonly
- #stage ⇒ RelatonBib::DocumentStatus::Stage readonly
- #substage ⇒ RelatonBib::DocumentStatus::Stage, NilClass readonly
Instance Method Summary collapse
-
#initialize(stage:, substage: nil, iteration: nil) ⇒ DocumentStatus
constructor
A new instance of DocumentStatus.
- #to_asciibib(prefix = "") ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(stage:, substage: nil, iteration: nil) ⇒ DocumentStatus
Returns a new instance of DocumentStatus.
20 21 22 23 24 |
# File 'lib/relaton_bib/document_status.rb', line 20 def initialize(stage:, substage: nil, iteration: nil) @stage = stage_new stage @substage = stage_new substage @iteration = iteration end |
Instance Attribute Details
#iteration ⇒ String, NilClass (readonly)
15 16 17 |
# File 'lib/relaton_bib/document_status.rb', line 15 def iteration @iteration end |
#stage ⇒ RelatonBib::DocumentStatus::Stage (readonly)
9 10 11 |
# File 'lib/relaton_bib/document_status.rb', line 9 def stage @stage end |
#substage ⇒ RelatonBib::DocumentStatus::Stage, NilClass (readonly)
12 13 14 |
# File 'lib/relaton_bib/document_status.rb', line 12 def substage @substage end |
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
46 47 48 49 50 51 52 |
# File 'lib/relaton_bib/document_status.rb', line 46 def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : prefix + "." out = "#{pref}docstatus.stage:: #{stage.value}\n" out += "#{pref}docstatus.substage:: #{substage.value}\n" if substage out += "#{pref}docstatus.iteration:: #{iteration}\n" if iteration out end |
#to_hash ⇒ Hash
37 38 39 40 41 42 |
# File 'lib/relaton_bib/document_status.rb', line 37 def to_hash hash = { "stage" => stage.to_hash } hash["substage"] = substage.to_hash if substage hash["iteration"] = iteration if iteration hash end |
#to_xml(builder) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/relaton_bib/document_status.rb', line 27 def to_xml(builder) builder.status do # FormattedString.instance_method(:to_xml).bind(status).call builder builder.stage { |b| stage.to_xml b } builder.substage { |b| substage.to_xml b } if substage builder.iteration iteration unless iteration.to_s.empty? end end |