Class: ThousandIsland::Components::Footer

Inherits:
Base
  • Object
show all
Defined in:
lib/thousand_island/components/footer.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #pdf

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#defaults, #draw, #initialize, #render_all

Constructor Details

This class inherits a constructor from ThousandIsland::Components::Base

Class Method Details

.default_numbering_optionsObject



79
80
81
82
83
84
# File 'lib/thousand_island/components/footer.rb', line 79

def self.default_numbering_options
  {
    align: :right,
    start_count_at: 1,
  }
end

.defaultsObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/thousand_island/components/footer.rb', line 67

def self.defaults
  {
    height: 33,
    top_padding: 20,
    repeated: true,
    numbering_options: default_numbering_options,
    number_pages: true,
    numbering_string: '<page>',
    style: {},
  }
end

Instance Method Details

#box_heightObject



51
52
53
# File 'lib/thousand_island/components/footer.rb', line 51

def box_height
  options[:height]
end

#col1Object



33
34
# File 'lib/thousand_island/components/footer.rb', line 33

def col1
end

#col1_widthObject



21
22
23
# File 'lib/thousand_island/components/footer.rb', line 21

def col1_width
  pdf.bounds.width * 0.15
end

#col2Object



36
37
38
39
40
41
42
# File 'lib/thousand_island/components/footer.rb', line 36

def col2
  start = col1_width
  pdf.bounding_box([start, box_height], width: col2_width, height: box_height) do
    inject_style
    yield if block_given?
  end
end

#col2_widthObject



25
26
27
# File 'lib/thousand_island/components/footer.rb', line 25

def col2_width
  pdf.bounds.width * 0.7
end

#col3Object



44
45
46
47
48
49
# File 'lib/thousand_island/components/footer.rb', line 44

def col3
  start = col1_width + col2_width
  pdf.bounding_box([start, box_height], width: col3_width, height: box_height) do
    pdf.number_pages numbering_string, numbering_options if number_pages?
  end
end

#col3_widthObject



29
30
31
# File 'lib/thousand_island/components/footer.rb', line 29

def col3_width
  pdf.bounds.width * 0.15
end

#inject_styleObject



63
64
65
# File 'lib/thousand_island/components/footer.rb', line 63

def inject_style
  options[:style].each { |k,v| pdf.send(k, v) if pdf.respond_to?(k) } if options[:style]
end

#number_pages?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/thousand_island/components/footer.rb', line 9

def number_pages?
  options[:number_pages]
end

#numbering_optionsObject



55
56
57
# File 'lib/thousand_island/components/footer.rb', line 55

def numbering_options
  options[:style].merge(options[:numbering_options])
end

#numbering_stringObject



5
6
7
# File 'lib/thousand_island/components/footer.rb', line 5

def numbering_string
  options[:numbering_string]
end

#render(&block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/thousand_island/components/footer.rb', line 13

def render(&block)
  pdf.bounding_box([0, box_height], width: pdf.bounds.width, height: box_height) do
    col1
    col2(&block)
    col3
  end
end

#repeated?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/thousand_island/components/footer.rb', line 59

def repeated?
  options[:repeated]
end