Class: RelatonIeee::EditorialGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_ieee/editorial_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ EditorialGroup

Initialize editorial group

Parameters:

  • **args (Hash)

    Hash of arguments

  • args (Hash)

    a customizable set of options

Options Hash (**args):

  • :society (String)

    Society

  • :balloting_group (RelatonIeee::BallotingGroup, Hash)

    Balloting group

  • :working_group (String)

    Working group

  • :committee (Array<String>)

    Committee



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/relaton_ieee/editorial_group.rb', line 19

def initialize(**args)
  unless args[:committee].is_a?(Array) && args[:committee].any?
    raise ArgumentError, ":committee is required"
  end

  @society = args[:society]
  @balloting_group = if args[:balloting_group].is_a?(Hash)
                       BallotingGroup.new(**args[:balloting_group])
                     else args[:balloting_group]
                     end
  @working_group = args[:working_group]
  @committee = args[:committee]
end

Instance Attribute Details

#balloting_groupRelatonIeee::BallotingGroup (readonly)

Returns Balloting group.

Returns:



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

def balloting_group
  @balloting_group
end

#committeeArray<String> (readonly)

Returns Committee.

Returns:

  • (Array<String>)

    Committee



8
9
10
# File 'lib/relaton_ieee/editorial_group.rb', line 8

def committee
  @committee
end

#societyString (readonly)

Returns:

  • (String)


4
5
6
# File 'lib/relaton_ieee/editorial_group.rb', line 4

def society
  @society
end

#working_groupString (readonly)

Returns:

  • (String)


4
5
6
# File 'lib/relaton_ieee/editorial_group.rb', line 4

def working_group
  @working_group
end

Instance Method Details

#presence?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/relaton_ieee/editorial_group.rb', line 33

def presence?
  true
end

#to_asciibib(prefix = "") ⇒ String

Render editorial group to AsciiBib

Parameters:

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

    Prefix

Returns:

  • (String)

    AsciiBib



72
73
74
75
76
77
78
79
80
81
# File 'lib/relaton_ieee/editorial_group.rb', line 72

def to_asciibib(prefix = "")
  pref = prefix.empty? ? prefix : "#{prefix}."
  pref += "editorialgroup"
  out = ""
  out += "#{pref}.society:: #{society}\n" if society
  out += balloting_group.to_asciibib(pref) if balloting_group
  out += "#{pref}.working-group:: #{working_group}\n" if working_group
  committee.each { |c| out += "#{pref}.committee:: #{c}\n" }
  out
end

#to_hashHash

Render editorial group to Hash

Returns:

  • (Hash)

    editorial group as Hash



56
57
58
59
60
61
62
63
# File 'lib/relaton_ieee/editorial_group.rb', line 56

def to_hash
  hash = {}
  hash["society"] = society if society
  hash["balloting_group"] = balloting_group.to_hash if balloting_group
  hash["working_group"] = working_group if working_group
  hash["committee"] = committee if committee
  hash
end

#to_xml(builder) ⇒ Object

Render editorial group to XML

Parameters:

  • builder (Nokogiri::XML::Builder)

    XML builder



42
43
44
45
46
47
48
49
# File 'lib/relaton_ieee/editorial_group.rb', line 42

def to_xml(builder)
  builder.editorialgroup do |b|
    b.society society if society
    balloting_group&.to_xml(b)
    b.send :"working-group", working_group if working_group
    committee.each { |c| b.committee c }
  end
end