Class: Asciibook::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/asciibook/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, node:) ⇒ Page

Returns a new instance of Page.



5
6
7
8
9
10
# File 'lib/asciibook/page.rb', line 5

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

  @footnotes = []
end

Instance Attribute Details

#footnotesObject

Returns the value of attribute footnotes.



3
4
5
# File 'lib/asciibook/page.rb', line 3

def footnotes
  @footnotes
end

#next_pageObject

Returns the value of attribute next_page.



3
4
5
# File 'lib/asciibook/page.rb', line 3

def next_page
  @next_page
end

#nodeObject

Returns the value of attribute node.



3
4
5
# File 'lib/asciibook/page.rb', line 3

def node
  @node
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/asciibook/page.rb', line 3

def path
  @path
end

#prev_pageObject

Returns the value of attribute prev_page.



3
4
5
# File 'lib/asciibook/page.rb', line 3

def prev_page
  @prev_page
end

Instance Method Details

#contentObject



16
17
18
# File 'lib/asciibook/page.rb', line 16

def content
  node.convert
end

#titleObject



12
13
14
# File 'lib/asciibook/page.rb', line 12

def title
  node.title
end

#to_hashObject



20
21
22
23
24
25
26
27
28
# File 'lib/asciibook/page.rb', line 20

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