Sha256: 43b9a8aadc82c46d064ecbd71815c8479a422d08f25709d683212d9fde415161

Contents?: true

Size: 976 Bytes

Versions: 24

Compression:

Stored size: 976 Bytes

Contents

module Lookbook
  # Represents a documentation page section.
  #
  # @ignore methods
  # @api private
  class PageSectionEntity < PageEntity
    attr_accessor :parent

    def initialize(file_path)
      @file_path = Pathname(file_path)
      @parent = nil
      super
    end

    def name
      Utils.name(name_parts[:name])
    end

    def lookup_path
      directory = if relative_directory_path.present? && !relative_directory_path.to_s.start_with?(".")
        relative_directory_path
      end

      path = PathUtils.to_path(directory, name_parts[:parent_name])
      PathUtils.to_lookup_path(path)
    end

    def landing?
      false
    end

    def url_path
      nil
    end

    alias_method :page, :parent

    protected

    def name_parts
      return @_name_parts if @_name_parts

      matches = file_name(true).match(/(?<parent_name>.*)\[(?<name>.*)\]/)
      @_name_parts ||= {name: matches[:name], parent_name: matches[:parent_name]}
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
lookbook-2.3.4 lib/lookbook/entities/page_section_entity.rb
lookbook-2.3.3 lib/lookbook/entities/page_section_entity.rb
lookbook-2.3.2 lib/lookbook/entities/page_section_entity.rb
lookbook-2.3.0 lib/lookbook/entities/page_section_entity.rb
lookbook-2.2.2 lib/lookbook/entities/page_section_entity.rb
lookbook-2.2.1 lib/lookbook/entities/page_section_entity.rb
lookbook-2.2.0 lib/lookbook/entities/page_section_entity.rb
lookbook-2.1.1 lib/lookbook/entities/page_section_entity.rb
lookbook-2.1.0 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.5 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.4 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.3 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.2 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.1 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.0 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.0.rc.3 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.0.rc.2 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.0.rc.1 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.0.beta.9 lib/lookbook/entities/page_section_entity.rb
lookbook-2.0.0.beta.8 lib/lookbook/entities/page_section_entity.rb