Class: RelatonBib::DocumentStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/document_status.rb

Overview

Document status.

Defined Under Namespace

Classes: Stage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage:, substage: nil, iteration: nil) ⇒ DocumentStatus

Returns a new instance of DocumentStatus.

Parameters:



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

#iterationString, NilClass (readonly)

Returns:

  • (String, NilClass)


15
16
17
# File 'lib/relaton_bib/document_status.rb', line 15

def iteration
  @iteration
end

#stageRelatonBib::DocumentStatus::Stage (readonly)



9
10
11
# File 'lib/relaton_bib/document_status.rb', line 9

def stage
  @stage
end

#substageRelatonBib::DocumentStatus::Stage, NilClass (readonly)

Returns:



12
13
14
# File 'lib/relaton_bib/document_status.rb', line 12

def substage
  @substage
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Parameters:

  • prefix (String) (defaults to: "")

Returns:

  • (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_hashHash

Returns:

  • (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

Parameters:

  • (Nokogiri::XML::Builder)


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