Class: RelatonBipm::WorkGroup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, acronym: nil) ⇒ WorkGroup

Returns a new instance of WorkGroup.

Parameters:

  • content (String)
  • acronym (String, nil) (defaults to: nil)


11
12
13
14
# File 'lib/relaton_bipm/workgroup.rb', line 11

def initialize(content:, acronym: nil)
  @content = content
  @acronym = acronym
end

Instance Attribute Details

#acronymString? (readonly)

Returns:

  • (String, nil)


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

def acronym
  @acronym
end

#contentString (readonly)

Returns:

  • (String)


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

def content
  @content
end

Instance Method Details

#to_asciibib(prefix, count = 1) ⇒ String

Parameters:

  • prefix (String)
  • count (Integer) (defaults to: 1)

Returns:

  • (String)


25
26
27
28
29
30
31
32
33
34
# File 'lib/relaton_bipm/workgroup.rb', line 25

def to_asciibib(prefix, count = 1)
  pref = prefix.empty? ? prefix : prefix + "."
  pref += "workgroup"
  if acronym
    out = count > 1 ? "#{pref}::\n" : ""
    out += "#{pref}.acronym:: #{acronym}\n"
    out + "#{pref}.content:: #{content}\n"
  else "#{pref}:: #{content}\n"
  end
end

#to_hashHash, String

Returns:

  • (Hash, String)


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

def to_hash
  if acronym
    hash = { "content" => content }
    hash["acronym"] = acronym
    hash
  else content
  end
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


17
18
19
20
# File 'lib/relaton_bipm/workgroup.rb', line 17

def to_xml(builder)
  xml = builder.workgroup content
  xml[:acronym] = acronym if acronym
end