Class: RelatonBipm::EditorialGroup

Inherits:
Object
  • Object
show all
Includes:
RelatonBib
Defined in:
lib/relaton_bipm/editorial_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(committee:, workgroup: []) ⇒ EditorialGroup

Returns a new instance of EditorialGroup.

Parameters:



13
14
15
16
# File 'lib/relaton_bipm/editorial_group.rb', line 13

def initialize(committee:, workgroup: [])
  @committee = committee
  @workgroup = workgroup
end

Instance Attribute Details

#committeeArray<RelatonBipm::Committee> (readonly)

Returns:



6
7
8
# File 'lib/relaton_bipm/editorial_group.rb', line 6

def committee
  @committee
end

#workgroupArray<RelatonBipm::WorkGroup> (readonly)

Returns:



9
10
11
# File 'lib/relaton_bipm/editorial_group.rb', line 9

def workgroup
  @workgroup
end

Instance Method Details

#presence?true

Returns:

  • (true)


46
47
48
# File 'lib/relaton_bipm/editorial_group.rb', line 46

def presence?
  true
end

#to_asciibib(prefix = "") ⇒ String

Parameters:

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

Returns:

  • (String)


28
29
30
31
32
33
34
35
# File 'lib/relaton_bipm/editorial_group.rb', line 28

def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize
  pref = prefix.empty? ? prefix : "#{prefix}."
  pref += "editorialgroup"
  out = ""
  committee.each { |c| out += c.to_asciibib pref, committee.size }
  workgroup.each { |w| out += w.to_asciibib pref, workgroup.size }
  out
end

#to_hashHash

Returns:

  • (Hash)


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

def to_hash
  hash = {}
  hash["committee"] = single_element_array(committee) if committee.any?
  hash["workgroup"] = single_element_array(workgroup) if workgroup.any?
  hash
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


19
20
21
22
23
24
# File 'lib/relaton_bipm/editorial_group.rb', line 19

def to_xml(builder)
  builder.editorialgroup do |b|
    committee.each { |c| c.to_xml b }
    workgroup.each { |c| c.to_xml b }
  end
end