Class: Booky::Layout::Base::UnnumberedList

Inherits:
Element
  • Object
show all
Includes:
Helpers
Defined in:
lib/booky/layout/base/unnumbered_list.rb

Constant Summary collapse

OPTIONS =
{
  :align => :justify,
  :size => 12,
  :inline_format => true
}

Instance Attribute Summary

Attributes inherited from Element

#ast, #document, #index, #options

Instance Method Summary collapse

Methods included from Helpers

#add_to_toc, #is_first_rendering?, #update_levels

Methods inherited from Element

#initialize, #method_missing, #next_option, #previous_option

Constructor Details

This class inherits a constructor from Booky::Layout::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Booky::Layout::Element

Instance Method Details

#make_page_breakObject



11
12
13
# File 'lib/booky/layout/base/unnumbered_list.rb', line 11

def make_page_break
  start_new_page if cursor + 2.cm < bounds.absolute_bottom
end

#to_prawnObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/booky/layout/base/unnumbered_list.rb', line 15

def to_prawn
  @options[:items].each do |item|
    indention = 1.cm * (item[:level] + 1)
    
    make_page_break
    
    fill_color Booky::Layout::Base::COLORS[1]
    fill_circle [indention - 0.3.cm, cursor - 0.2.cm], 0.07.cm
    fill_color Booky::Layout::Base::COLORS[0]
    
    span(bounds.width - indention, :position => indention) do
      text item[:text], OPTIONS
    end
    
    move_down 0.2.cm
  end
  
  move_down 0.5.cm
end