Class: RelatonBib::WorkGroup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, number: nil, type: nil) ⇒ WorkGroup



15
16
17
18
19
# File 'lib/relaton_bib/workgroup.rb', line 15

def initialize(content:, number: nil, type: nil)
  @content = content
  @number = number
  @type = type
end

Instance Attribute Details

#contentString (readonly)



4
5
6
# File 'lib/relaton_bib/workgroup.rb', line 4

def content
  @content
end

#numberInteger? (readonly)



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

def number
  @number
end

#typeString? (readonly)



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

def type
  @type
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String



38
39
40
41
42
43
44
# File 'lib/relaton_bib/workgroup.rb', line 38

def to_asciibib(prefix = "")
  pref = prefix.empty? ? prefix : prefix + "."
  out = "#{pref}content:: #{content}\n"
  out += "#{pref}number:: #{number}\n" if number
  out += "#{pref}type:: #{type}\n" if type
  out
end

#to_hashHash



29
30
31
32
33
34
# File 'lib/relaton_bib/workgroup.rb', line 29

def to_hash
  hash = { "content" => content }
  hash["number"] = number if number
  hash["type"] = type if type
  hash
end

#to_xml(builder) ⇒ Object



22
23
24
25
26
# File 'lib/relaton_bib/workgroup.rb', line 22

def to_xml(builder)
  builder.text content
  builder.parent[:number] = number if number
  builder.parent[:type] = type if type
end