Module: Visual
- Included in:
- Barcode
- Defined in:
- lib/visual.rb
Overview
Methods to visualize a barcode
Instance Method Summary collapse
-
#to_pdf(pdf, options = {}) ⇒ Object
Adds a barcode to a pdf file.
Instance Method Details
#to_pdf(pdf, options = {}) ⇒ Object
Adds a barcode to a pdf file
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/visual.rb', line 7 def to_pdf(pdf, ={}) pdf.undash () @graph[:bars].each do |b| pdf.move_to(b[:x], @graph[:y]) pdf.line_to(b[:x], @graph[:y] + @graph[:height]) pdf.line_to(b[:x] + b[:width], @graph[:y] + @graph[:height]) pdf.line_to(b[:x] + b[:width], @graph[:y]) pdf.line_to(b[:x], @graph[:y]) pdf.fill end if @options[:bearer] == :frame pdf.move_to(@options[:x], @graph[:y]) pdf.line_to(@options[:x], @graph[:y] + @graph[:height]) pdf.line_to(@options[:x] + 2 * @options[:quiet] + @graph[:graph_width], @graph[:y] + @graph[:height]) pdf.line_to(@options[:x] + 2 * @options[:quiet] + @graph[:graph_width], @graph[:y]) pdf.line_to(@options[:x], @graph[:y]) elsif @options[:bearer] == :rule pdf.move_to(@options[:x], @options[:y] + @options[:bottom_margin] + @graph[:height]) pdf.line_to(@options[:x] + 2 * @options[:quiet] + @graph[:graph_width], @options[:y] + @options[:bottom_margin] + @graph[:height]) pdf.move_to(@options[:x] + 2 * @options[:quiet] + @graph[:graph_width], @options[:y] + @options[:bottom_margin]) pdf.line_to(@options[:x], @options[:y] + @options[:bottom_margin]) end @graph end |