Class: Prawn::SwissQRBill::Sections::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/swiss_qr_bill/sections/section.rb

Overview

Section main class which can draw itself at the right position.

Subclasses shall implement the draw method with the box block:

def draw
  box do
    doc.text 'example'
    draw_something
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, data, options = {}) ⇒ Section

Returns a new instance of Section.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/prawn/swiss_qr_bill/sections/section.rb', line 22

def initialize(document, data, options = {})
  unless self.class.const_defined?(:KEY)
    raise NotImplementedError, "constant KEY not defined in class #{self.class}"
  end

  @doc = document
  @data = data
  @options = options || {}

  load_specs
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



17
18
19
# File 'lib/prawn/swiss_qr_bill/sections/section.rb', line 17

def doc
  @doc
end

#specsObject

specifications for subclass’ section, @see Specification for details



20
21
22
# File 'lib/prawn/swiss_qr_bill/sections/section.rb', line 20

def specs
  @specs
end

Instance Method Details

#drawObject

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/prawn/swiss_qr_bill/sections/section.rb', line 34

def draw
  raise NotImplementedError, 'Subcluss must implement draw method.'
end