Sha256: cead79312d6bef3e257e483c3e8acc4ca9dfb74d474b84245788bdc6e5a7cefb

Contents?: true

Size: 829 Bytes

Versions: 11

Compression:

Stored size: 829 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/recursive_builder'

module Avm
  module EacAsciidoctorBase0
    module DocumentsOwner
      common_concern

      # @param subpath [Pathname]
      # @return [Avm::EacAsciidoctorBase0::Sources::Document]
      # @raise [KeyError]
      def document(subpath)
        documents.find { |d| d.subpath.to_pathname == subpath.to_pathname } ||
          raise(::KeyError, "Document not found with subáth = \"#{subpath}\"")
      end

      # @return [Enumerable<Avm::EacAsciidoctorBase0::Sources::Document>]
      def documents
        ::EacRubyUtils::RecursiveBuilder.new(root_document, &:children).result
      end

      # @return [Object]
      def root_document
        raise "Abstract method hit: #{__method__}"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
avm-eac_asciidoctor_base0-0.23.0 lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.88.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.87.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb
avm-eac_asciidoctor_base0-0.22.1 lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.86.13 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb
avm-eac_asciidoctor_base0-0.22.0 lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.85.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.84.2 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.84.1 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb
avm-eac_asciidoctor_base0-0.21.0 lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.84.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb