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:



18
19
20
21
22
# File 'lib/relaton_bib/document_status.rb', line 18

def initialize(stage:, substage: nil, iteration: nil)
  @stage = stage_new stage
  @substage = stage_new substage
  @iteration = iteration
end

Instance Attribute Details

#iterationString? (readonly)

Returns:

  • (String, nil)


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

def iteration
  @iteration
end

#stageRelatonBib::DocumentStatus::Stage (readonly)



7
8
9
# File 'lib/relaton_bib/document_status.rb', line 7

def stage
  @stage
end

#substageRelatonBib::DocumentStatus::Stage? (readonly)



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

def substage
  @substage
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Parameters:

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

Returns:

  • (String)


44
45
46
47
48
49
50
# File 'lib/relaton_bib/document_status.rb', line 44

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)


35
36
37
38
39
40
# File 'lib/relaton_bib/document_status.rb', line 35

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)


25
26
27
28
29
30
31
32
# File 'lib/relaton_bib/document_status.rb', line 25

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