class RelatonItu::ItuGroup
Constants
- TYPES
Attributes
acronym[R]
@return [String, NilClass]
name[R]
@return [String]
period[R]
@return [RelatonItu::ItuGroup::Period, NilClass] group period
type[R]
@return [String, NilClass]
Public Class Methods
new(type: nil, name:, acronym: nil, period: nil)
click to toggle source
@param type [String, NilClass] @param name [String] @param acronym [String, NilClass] @param period [Hash, RelatonItu::ItuGroup::Period
, NilClass]
# File lib/relaton_itu/itu_group.rb, line 58 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
Public Instance Methods
to_asciibib(prefix)
click to toggle source
@param prefix [String] @return [String]
# File lib/relaton_itu/itu_group.rb, line 88 def to_asciibib(prefix) pref = prefix.empty? ? prefix : prefix + "." out = "#{pref}name:: #{name}\n" out += "#{pref}type:: #{type}\n" if type out += "#{pref}acronym:: #{acronym}\n" if acronym out += period.to_asciibib prefix if period out end
to_hash()
click to toggle source
@return [Hash]
# File lib/relaton_itu/itu_group.rb, line 78 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)
click to toggle source
@param builder [Nokogiri::XML::Builder]
# File lib/relaton_itu/itu_group.rb, line 70 def to_xml(builder) builder.parent[:type] = type if type builder.name name builder.acronym acronym if acronym period&.to_xml builder end