Class: Bookify::Node::H1

Inherits:
Base
  • Object
show all
Defined in:
lib/bookify/node/h1.rb

Constant Summary

Constants inherited from Base

Base::FONTS

Instance Attribute Summary

Attributes inherited from Base

#node, #pdf

Instance Method Summary collapse

Methods inherited from Base

#break_if_close_to_bottom, #clean_html, #decode_html, #font, #html_classes, #initialize, #method_missing, render

Constructor Details

This class inherits a constructor from Bookify::Node::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bookify::Node::Base

Instance Method Details

#page_topObject



22
23
24
# File 'lib/bookify/node/h1.rb', line 22

def page_top
  pdf.bounds.parent.height + 50
end

#renderObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bookify/node/h1.rb', line 5

def render
  break_if_close_to_bottom(250)
  move_down 20 unless pdf.y == page_top

  html = decode_html(node.inner_html.strip)
  dest = dest_xyz(0, pdf.y, nil, pdf.page)

  Bookify::Sections.add(:h1, html, dest)
  add_dest(html, dest)

  font :h1 do
    text html, align: :center
  end

  move_down 10
end