Sha256: aacc38f29ee900ae2ffacf3c7de5960799a7b9cb6e4828cc8b4654a4690eafbe

Contents?: true

Size: 1.72 KB

Versions: 30

Compression:

Stored size: 1.72 KB

Contents

module RelatonIho
  class EditorialGroupCollection
    extend Forwardable

    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, Array<Hash>]
    def to_hash
      collection.map &:to_hash
    end

    # @param prefix [String]
    # @return [String]
    def to_asciibib(prefix)
      collection.map { |ed| ed.to_asciibib prefix, collection.size }.join
    end

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

  class EditorialGroup
    include RelatonBib

    # @return [Array<RelatonIho::Committee, RelatonIho::Commission,
    #          RelatonIho::Workgroup>]
    attr_accessor :workgroup

    # @param workgroup [Array<RelatonIho::Committee, RelatonIho::Commission,
    #                   RelatonIho::Workgroup>]
    def initialize(workgroup)
      @workgroup = workgroup
    end

    # @param builder [Nokogiro::XML::Builder]
    def to_xml(builder)
      builder.editorialgroup do
        workgroup.each { |wg| wg.to_xml builder }
      end
    end

    # @return [Hash, Array<Hash>]
    def to_hash
      single_element_array workgroup
    end

    # @param prefix [String]
    # @param count [Integer]
    # @return [Strin]
    def to_asciibib(prefix, count)
      pref = prefix.empty? ? prefix : prefix + "."
      pref += "editorialgroup"
      out = count > 1 ? "#{pref}::\n" : ""
      workgroup.each { |wg| out += wg.to_asciibib pref, workgroup.size }
      out
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
relaton-iho-1.19.1 lib/relaton_iho/editorial_group.rb
relaton-iho-1.19.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.18.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.17.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.16.2 lib/relaton_iho/editorial_group.rb
relaton-iho-1.16.1 lib/relaton_iho/editorial_group.rb
relaton-iho-1.16.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.14.3 lib/relaton_iho/editorial_group.rb
relaton-iho-1.14.2 lib/relaton_iho/editorial_group.rb
relaton-iho-1.14.1 lib/relaton_iho/editorial_group.rb
relaton-iho-1.14.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.13.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.12.1 lib/relaton_iho/editorial_group.rb
relaton-iho-1.12.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.11.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.10.2 lib/relaton_iho/editorial_group.rb
relaton-iho-1.10.1 lib/relaton_iho/editorial_group.rb
relaton-iho-1.10.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.9.0 lib/relaton_iho/editorial_group.rb
relaton-iho-1.8.0 lib/relaton_iho/editorial_group.rb