| Class | Barby::ASCIIOutputter |
| In: |
lib/barby/outputter/ascii_outputter.rb
|
| Parent: | Outputter |
Outputs an ASCII representation of the barcode. This is mostly useful for printing the barcode directly to the terminal for testing.
Registers to_ascii
# File lib/barby/outputter/ascii_outputter.rb, line 14
14: def to_ascii(opts={})
15: default_opts = {:height => 10, :xdim => 1, :bar => '#', :space => ' '}
16: default_opts.update(:height => 1, :bar => ' X ', :space => ' ') if barcode.two_dimensional?
17: opts = default_opts.merge(opts)
18:
19: if barcode.two_dimensional?
20: booleans.map do |bools|
21: line_to_ascii(bools, opts)
22: end.join("\n")
23: else
24: line_to_ascii(booleans, opts)
25: end
26: end