Class: Sugpoko::Base
- Inherits:
-
Object
- Object
- Sugpoko::Base
- Includes:
- Prawn::View
- Defined in:
- lib/sugpoko/base.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#pdf ⇒ Object
readonly
Returns the value of attribute pdf.
Instance Method Summary collapse
- #base_attributes ⇒ Object
- #configure(options = {}) ⇒ Object
- #default_options ⇒ Object
- #document ⇒ Object
- #draw(klass, options = {}) ⇒ Object
- #generate ⇒ Object
- #height ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #margin ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
25 26 27 28 29 |
# File 'lib/sugpoko/base.rb', line 25 def initialize( = {}) @data = [:data] @pdf = self configure end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/sugpoko/base.rb', line 3 def data @data end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
3 4 5 |
# File 'lib/sugpoko/base.rb', line 3 def page_size @page_size end |
#pdf ⇒ Object (readonly)
Returns the value of attribute pdf.
3 4 5 |
# File 'lib/sugpoko/base.rb', line 3 def pdf @pdf end |
Instance Method Details
#base_attributes ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/sugpoko/base.rb', line 15 def base_attributes { pdf: pdf, width: width - margin * 2, height: height - margin * 2, position: [0, pdf.cursor], data: data } end |
#configure(options = {}) ⇒ Object
31 32 |
# File 'lib/sugpoko/base.rb', line 31 def configure( = {}) end |
#default_options ⇒ Object
50 51 52 53 54 55 |
# File 'lib/sugpoko/base.rb', line 50 def @default_options ||= { page_size: [width, height], page_layout: :portrait } end |
#document ⇒ Object
46 47 48 |
# File 'lib/sugpoko/base.rb', line 46 def document @document ||= Prawn::Document.new() end |
#draw(klass, options = {}) ⇒ Object
11 12 13 |
# File 'lib/sugpoko/base.rb', line 11 def draw(klass, = {}) klass.new(base_attributes.merge()).generate end |
#generate ⇒ Object
7 8 9 |
# File 'lib/sugpoko/base.rb', line 7 def generate raise '#generate not defined' end |
#height ⇒ Object
38 39 40 |
# File 'lib/sugpoko/base.rb', line 38 def height 11.in end |
#margin ⇒ Object
42 43 44 |
# File 'lib/sugpoko/base.rb', line 42 def margin 0.5.in end |
#width ⇒ Object
34 35 36 |
# File 'lib/sugpoko/base.rb', line 34 def width 8.5.in end |