Sha256: 16f113535a3f58ef51ee208f712be51e0d42509a35e43e4c04d938dca945ea81

Contents?: true

Size: 602 Bytes

Versions: 4

Compression:

Stored size: 602 Bytes

Contents

module Asciibook
  class Page
    attr_accessor :path, :node, :prev_page, :next_page, :footnotes

    def initialize(path:, node:)
      @path = path
      @node = node

      @footnotes = []
    end

    def title
      node.title
    end

    def content
      node.convert
    end

    def to_hash
      {
        'path' => path,
        'title' => title,
        'content' => content,
        'prev_page' => prev_page && { 'path' => prev_page.path, 'title' => prev_page.title },
        'next_page' => next_page && { 'path' => next_page.path, 'title' => next_page.title }
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asciibook-0.0.2 lib/asciibook/page.rb
asciibook-0.0.2.beta2 lib/asciibook/page.rb
asciibook-0.0.2.beta1 lib/asciibook/page.rb
asciibook-0.0.1 lib/asciibook/page.rb