Class: RubyDanfe::Document
- Inherits:
-
Prawn::Document
- Object
- Prawn::Document
- RubyDanfe::Document
- Defined in:
- lib/ruby_danfe.rb
Instance Method Summary collapse
- #box(at, w, h, title = '', info = '', options = {}) ⇒ Object
- #ibarcode(h, w, x, y, info) ⇒ Object
- #ibox(h, w, x, y, title = '', info = '', options = {}) ⇒ Object
- #idate(h, w, x, y, title = '', info = '', options = {}) ⇒ Object
- #inumeric(h, w, x, y, title = '', info = '', options = {}) ⇒ Object
- #irectangle(h, w, x, y) ⇒ Object
- #itable(h, w, x, y, data, options = {}, &block) ⇒ Object
- #ititle(h, w, x, y, title) ⇒ Object
- #numeric(at, w, h, title = '', info = '', options = {}) ⇒ Object
Instance Method Details
#box(at, w, h, title = '', info = '', options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ruby_danfe.rb', line 68 def box(at, w, h, title = '', info = '', = {}) = { :align => :left, :size => 10, :style => nil, :valign => :top, :border => 1 }.merge() self.stroke_rectangle at, w, h if [:border] == 1 self.text_box title, :size => 6, :at => [at[0] + 2, at[1] - 2], :width => w - 4, :height => 8 if title != '' self.text_box info, :size => [:size], :at => [at[0] + 2, at[1] - (title != '' ? 14 : 4) ], :width => w - 4, :height => h - (title != '' ? 14 : 4), :align => [:align], :style => [:style], :valign => [:valign] end |
#ibarcode(h, w, x, y, info) ⇒ Object
51 52 53 |
# File 'lib/ruby_danfe.rb', line 51 def (h, w, x, y, info) Barby::Code128C.new(info).annotate_pdf(self, :x => x.cm, :y => invert(y.cm), :width => w.cm, :height => h.cm) if info != '' end |
#ibox(h, w, x, y, title = '', info = '', options = {}) ⇒ Object
59 60 61 |
# File 'lib/ruby_danfe.rb', line 59 def ibox(h, w, x, y, title = '', info = '', = {}) box [x.cm, invert(y.cm)], w.cm, h.cm, title, info, end |
#idate(h, w, x, y, title = '', info = '', options = {}) ⇒ Object
63 64 65 66 |
# File 'lib/ruby_danfe.rb', line 63 def idate(h, w, x, y, title = '', info = '', = {}) tt = info.split('-') ibox h, w, x, y, title, "#{tt[2]}/#{tt[1]}/#{tt[0]}", end |
#inumeric(h, w, x, y, title = '', info = '', options = {}) ⇒ Object
81 82 83 |
# File 'lib/ruby_danfe.rb', line 81 def inumeric(h, w, x, y, title = '', info = '', = {}) numeric [x.cm, invert(y.cm)], w.cm, h.cm, title, info, end |
#irectangle(h, w, x, y) ⇒ Object
55 56 57 |
# File 'lib/ruby_danfe.rb', line 55 def irectangle(h, w, x, y) self.stroke_rectangle [x.cm, invert(y.cm)], w.cm, h.cm end |
#itable(h, w, x, y, data, options = {}, &block) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/ruby_danfe.rb', line 91 def itable(h, w, x, y, data, = {}, &block) self.bounding_box [x.cm, invert(y.cm)], :width => w.cm, :height => h.cm do self.table data, do |table| yield(table) end end end |
#ititle(h, w, x, y, title) ⇒ Object
47 48 49 |
# File 'lib/ruby_danfe.rb', line 47 def ititle(h, w, x, y, title) self.text_box title, :size => 10, :at => [x.cm, invert(y.cm) - 2], :width => w.cm, :height => h.cm, :style => :bold end |
#numeric(at, w, h, title = '', info = '', options = {}) ⇒ Object
85 86 87 88 89 |
# File 'lib/ruby_danfe.rb', line 85 def numeric(at, w, h, title = '', info = '', = {}) = {:decimals => 2}.merge() info = numerify(info, [:decimals]) if info != '' box at, w, h, title, info, .merge({:align => :right}) end |