Class: ThousandIsland::Components::Base

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

Direct Known Subclasses

Body, Footer, Header

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdf, args = nil) ⇒ Base



7
8
9
10
# File 'lib/thousand_island/components/base.rb', line 7

def initialize(pdf, args=nil)
  @options = args || self.defaults
  @pdf = pdf
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#pdfObject (readonly)

Returns the value of attribute pdf.



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

def pdf
  @pdf
end

Class Method Details

.defaultsObject



34
35
36
# File 'lib/thousand_island/components/base.rb', line 34

def self.defaults
  {}
end

Instance Method Details

#defaultsObject



38
39
40
# File 'lib/thousand_island/components/base.rb', line 38

def defaults
  self.class.defaults
end

#draw(&block) ⇒ Object



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

def draw(&block)
  if repeated?
    render_all &block
  else
    render &block
  end
end

#render(&block) ⇒ Object

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/thousand_island/components/base.rb', line 26

def render(&block)
  raise NotImplementedError
end

#render_all(&block) ⇒ Object



20
21
22
23
24
# File 'lib/thousand_island/components/base.rb', line 20

def render_all(&block)
  pdf.repeat :all do
    render &block
  end
end

#repeated?Boolean



30
31
32
# File 'lib/thousand_island/components/base.rb', line 30

def repeated?
  false
end