Sha256: 651f1237364ec8bb3197fe4bce48d3c24b7500ba831b563435931814e58cab1b

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module RelatonIho
  class EditorialGroupCollection
    extend Forwardable
    include RelatonBib

    def_delegators :@collection, :first, :any?

    # @return [Array<RelatonIho::editorialgroup]
    attr_reader :collection

    # @param collection [Array<RelatonIho::EditorialGroup>]
    def initialize(collection)
      @collection = collection
    end

    # @param builder [Nokogiro::XML::Builder]
    def to_xml(builder)
      collection.each { |eg| eg.to_xml builder }
    end

    # @return [Hash]
    def to_hash
      single_element_array collection
    end

    # @return [Boolean]
    def presence?
      any?
    end
  end

  class EditorialGroup
    # @return [String]
    attr_reader :committee, :workgroup

    # @parma committee [String]
    # @param workgroup [String]
    def initialize(committee:, workgroup:)
      unless %[hssc ircc].include? committee
        warn "[relaton-iho] WARNING: invalid committee: #{committee}"
      end
      @committee = committee
      @workgroup = workgroup
    end

    # @param builder [Nokogiro::XML::Builder]
    def to_xml(builder)
      builder.editorialgroup do
        builder.committee committee
        builder.workgroup workgroup
      end
    end

    # @return [Hash]
    def to_hash
      { "committee" => committee, "workgroup" => workgroup }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-iho-1.2.0 lib/relaton_iho/editorial_group.rb