Class: Booky::Layout::Base::Blockquote

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

Constant Summary collapse

OPTIONS =
{
  :align => :justify,
  :size => 14,
  :style => :italic_light,
  :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

#start_new_page_if_neededObject



12
13
14
# File 'lib/booky/layout/base/blockquote.rb', line 12

def start_new_page_if_needed
  start_new_page if cursor < (bounds.bottom + 4.cm)
end

#to_prawnObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/booky/layout/base/blockquote.rb', line 16

def to_prawn
  start_new_page_if_needed
  
  citation = "(#{@options[:author]}"
  citation << " #{@options[:year]}"   if @options[:year]
  citation << ", #{@options[:pages]}" if @options[:pages]
  citation << ")"
  citation = "" unless @options[:author]
  
  data = []
  data << [make_cell(
    :content        => citation,
    :size           => 10, 
    :font_style     => :normal,
    :align          => :right,
    :border_width   => 1, 
    :borders        => [:bottom]
  )]
  data << [make_cell(
    :content        => @options[:text].chop,
    :size           => 12, 
    :font_style     => :italic, 
    :border_width   => 1, 
    :borders        => [:bottom]
  )]
  
  
  table(data,
    :header => false,
    :width => bounds.width - 2.cm,
    :position => :center,
    :row_colors => ['FFFFFF', Booky::Layout::Base::COLORS[3]],
    :cell_style => { 
      :inline_format => true, 
      :border_color => Booky::Layout::Base::COLORS[2], 
      :border_width => 0.5
    }
  )
  move_down 1.cm
end