Class: RelatonItu::ItuGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_itu/itu_group.rb

Defined Under Namespace

Classes: Period

Constant Summary collapse

TYPES =
%w[tsag study-group work-group].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, name:, acronym: nil, period: nil) ⇒ ItuGroup

Returns a new instance of ItuGroup.

Parameters:

  • type (String, NilClass) (defaults to: nil)
  • name (String)
  • acronym (String, NilClass) (defaults to: nil)
  • period (RelatonItu::ItuGroup::Period, NilClass) (defaults to: nil)


41
42
43
44
45
46
47
48
49
50
# File 'lib/relaton_itu/itu_group.rb', line 41

def initialize(type: nil, name:, acronym: nil, period: nil)
  if type && !TYPES.include?(type)
    raise ArgumentError, "invalid type: #{type}"
  end

  @type = type
  @name = name
  @acronym = acronym
  @period = period
end

Instance Attribute Details

#acronymString, NilClass (readonly)

Returns:

  • (String, NilClass)


32
33
34
# File 'lib/relaton_itu/itu_group.rb', line 32

def acronym
  @acronym
end

#nameString (readonly)

Returns:

  • (String)


29
30
31
# File 'lib/relaton_itu/itu_group.rb', line 29

def name
  @name
end

#periodRelatonItu::ItuGroup::Period, NilClass (readonly)

Returns group period.

Returns:



35
36
37
# File 'lib/relaton_itu/itu_group.rb', line 35

def period
  @period
end

#typeString, NilClass (readonly)

Returns:

  • (String, NilClass)


32
33
34
# File 'lib/relaton_itu/itu_group.rb', line 32

def type
  @type
end

Instance Method Details

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


53
54
55
56
57
58
# File 'lib/relaton_itu/itu_group.rb', line 53

def to_xml(builder)
  builder.parent[:type] = type if type
  builder.name name
  builder.acronym acronym if acronym
  period&.to_xml builder
end