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:



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

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)


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

def iteration
  @iteration
end

#stageRelatonBib::DocumentStatus::Stage (readonly)



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

def stage
  @stage
end

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

Returns:



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

def substage
  @substage
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Parameters:

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

Returns:

  • (String)


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

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)


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

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)


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

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