Sha256: 944833728168b8cc509d5e80ab75a2ca2c51b6691753a15eb2de807be6bfcc6d

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require "forwardable"

module RelatonBib
  # Document relation collection
  class DocRelationCollection
    extend Forwardable

    def_delegators :@array, :<<, :[], :first, :last, :empty?, :any?, :size,
                   :each, :detect, :map, :length

    # @param relation [Array<RelatonBib::DocumentRelation, Hash>]
    # @option relation [String] :type
    # @option relation [String] :identifier
    # @option relation [String, NIllClass] :url (nil)
    # @option relation [Array<RelatonBib::Locality,
    #                   RelatonBib::LocalityStack>] :locality
    # @option relation [Array<RelatonBib::SourceLocality,
    #                   RelatonBib::SourceLocalityStack>] :source_locality
    # @option relation [RelatonBib::BibliographicItem, NillClass] :bibitem (nil)
    def initialize(relation)
      @array = relation.map { |r| r.is_a?(Hash) ? DocumentRelation.new(r) : r }
    end

    # @todo We don't have replace type anymore. Suppose we should update this
    #   method or delete it.
    #
    # @return [RelatonBib::DocRelationCollection]
    def replaces
      DocRelationCollection.new(@array.select { |r| r.type == "replace" })
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/relaton-bib-1.2.4/lib/relaton_bib/document_relation_collection.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/relaton-bib-1.2.4/lib/relaton_bib/document_relation_collection.rb
relaton-bib-1.2.4 lib/relaton_bib/document_relation_collection.rb
relaton-bib-1.2.2 lib/relaton_bib/document_relation_collection.rb
relaton-bib-1.2.1 lib/relaton_bib/document_relation_collection.rb
relaton-bib-1.2.0 lib/relaton_bib/document_relation_collection.rb
relaton-bib-1.1.1 lib/relaton_bib/document_relation_collection.rb