Sha256: 3911ba43d218439eb91ab3b8ecd75e4b3ac6f73395cb15dc9f7e7554fd48cb7f

Contents?: true

Size: 829 Bytes

Versions: 4

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 subpath = \"#{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

4 entries across 4 versions & 2 rubygems

Version Path
avm-eac_asciidoctor_base0-0.25.0 lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.97.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb
avm-eac_asciidoctor_base0-0.24.0 lib/avm/eac_asciidoctor_base0/documents_owner.rb
eac_tools-0.96.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/documents_owner.rb