Sha256: f587c35fad6bc33354a7c72d2a593268d794bd32442ea830d242fb87d564a18e
Contents?: true
Size: 1.85 KB
Versions: 27
Compression:
Stored size: 1.85 KB
Contents
module RelatonItu class ItuGroup class Period # @return [String] group period start year attr_reader :start # @return [String, NilClass] group period end year attr_reader :finish # @params start [String] # @params finish [String, NilClass] def initialize(start:, finish: nil) @start = start @finish = finish end # @param builder [Nokogiri::XML::Builder] def to_xml(builder) builder.period do builder.start start builder.end finish if finish end end # @return [Hash] def to_hash hash = { "start" => start } hash["finish"] = finish if finish hash end end TYPES = %w[tsag study-group work-group].freeze # @return [String] attr_reader :name # @return [String, NilClass] attr_reader :type, :acronym # @return [RelatonItu::ItuGroup::Period, NilClass] group period attr_reader :period # @param type [String, NilClass] # @param name [String] # @param acronym [String, NilClass] # @param period [Hash, RelatonItu::ItuGroup::Period, NilClass] 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 # @param builder [Nokogiri::XML::Builder] def to_xml(builder) builder.parent[:type] = type if type builder.name name builder.acronym acronym if acronym period&.to_xml builder end # @return [Hash] 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 end end
Version data entries
27 entries across 27 versions & 2 rubygems