Sha256: ef64116790f8fa8564cef0c00d9fc29844d8f2bbbaefcdc468da1054ff040c45

Contents?: true

Size: 1.8 KB

Versions: 22

Compression:

Stored size: 1.8 KB

Contents

module RelatonOgc
  # OGC project group.
  class EditorialGroup
    include RelatonBib

    COMMITTEES = %w[technical planning strategic-member-advisory].freeze

    # @return [String]
    attr_reader :committee

    # @return [RelatonIsoBib::IsoSubgroup]
    attr_reader :subcommittee

    # @return [RelatonIsoBib::IsoSubgroup]
    attr_reader :workgroup

    # @param committee [String]
    #
    # @param subcommittee [Hash, RelatonIsoBib::IsoSubgroup]
    # @option subcommittee [String] :name
    # @option subcommittee [String] :type
    # @option subcommittee [Integer] :number
    #
    # @param workgroup [Hash, RelatonIsoBib::IsoSubgroup]
    # @option workgroup [String] :name
    # @option workgroup [String] :type
    # @option workgroup [Integer] :number
    def initialize(committee:, **args)
      unless COMMITTEES.include? committee
        raise ArgumentError, "committee is invalid: #{committee}"
      end

      @committee    = committee
      @subcommittee = subgroup args[:subcommittee]
      @workgroup    = subgroup args[:workgroup]
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.editorialgroup do
        builder.committee committee
        builder.subcommittee { subcommittee&.to_xml builder } if subcommittee
        builder.workgroup { workgroup&.to_xml builder } if workgroup
      end
    end

    # @return [Hash]
    def to_hash
      hash = { "committee" => committee }
      hash["subcommittee"] = subcommittee.to_hash if subcommittee
      hash["workgroup"] = workgroup.to_hash if workgroup
      hash
    end

    private

    # @param group [Hash, RelatonIsoBib::IsoSubgroup]
    # @return {RelatonIsoBib::IsoSubgroup}
    def subgroup(group)
      if group.is_a?(Hash)
        RelatonIsoBib::IsoSubgroup.new(group)
      else group
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/relaton-ogc-1.2.0/lib/relaton_ogc/editorial_group.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/relaton-ogc-1.2.0/lib/relaton_ogc/editorial_group.rb
relaton-ogc-1.2.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-1.1.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-1.0.1 lib/relaton_ogc/editorial_group.rb
relaton-ogc-1.0.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.7.3 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.7.2 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.7.1 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.7.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.6.1 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.6.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.5.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.4.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.3.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.2.1 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.2.0 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.1.4 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.1.3 lib/relaton_ogc/editorial_group.rb
relaton-ogc-0.1.2 lib/relaton_ogc/editorial_group.rb