Class: RelatonItu::ItuGroup
- Inherits:
-
Object
- Object
- RelatonItu::ItuGroup
- 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
- #acronym ⇒ String, NilClass readonly
- #name ⇒ String readonly
-
#period ⇒ RelatonItu::ItuGroup::Period, NilClass
readonly
Group period.
- #type ⇒ String, NilClass readonly
Instance Method Summary collapse
-
#initialize(type: nil, name:, acronym: nil, period: nil) ⇒ ItuGroup
constructor
A new instance of ItuGroup.
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(type: nil, name:, acronym: nil, period: nil) ⇒ ItuGroup
Returns a new instance of ItuGroup.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/relaton_itu/itu_group.rb', line 48 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.is_a?(Hash) ? Period.new(period) : period end |
Instance Attribute Details
#acronym ⇒ String, NilClass (readonly)
39 40 41 |
# File 'lib/relaton_itu/itu_group.rb', line 39 def acronym @acronym end |
#name ⇒ String (readonly)
36 37 38 |
# File 'lib/relaton_itu/itu_group.rb', line 36 def name @name end |
#period ⇒ RelatonItu::ItuGroup::Period, NilClass (readonly)
Returns group period.
42 43 44 |
# File 'lib/relaton_itu/itu_group.rb', line 42 def period @period end |
#type ⇒ String, NilClass (readonly)
39 40 41 |
# File 'lib/relaton_itu/itu_group.rb', line 39 def type @type end |
Instance Method Details
#to_hash ⇒ Hash
68 69 70 71 72 73 74 |
# File 'lib/relaton_itu/itu_group.rb', line 68 def to_hash hash = { "name" => name } hash["type"] = type if type hash["acronym"] = acronym if acronym hash["period"] = period.to_hash if period hash end |
#to_xml(builder) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/relaton_itu/itu_group.rb', line 60 def to_xml(builder) builder.parent[:type] = type if type builder.name name builder.acronym acronym if acronym period&.to_xml builder end |