Class: Chords::PDFFormatter
- Inherits:
-
Object
- Object
- Chords::PDFFormatter
- Defined in:
- lib/chords/pdf_formatter.rb
Instance Method Summary collapse
-
#initialize(fretboard) ⇒ PDFFormatter
constructor
A new instance of PDFFormatter.
- #print(title, fingerings, opts = {}) ⇒ Object
Constructor Details
#initialize(fretboard) ⇒ PDFFormatter
Returns a new instance of PDFFormatter.
9 10 11 |
# File 'lib/chords/pdf_formatter.rb', line 9 def initialize(fretboard) @fretboard = fretboard end |
Instance Method Details
#print(title, fingerings, opts = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chords/pdf_formatter.rb', line 13 def print(title, fingerings, opts={}) @pdf = Prawn::Document.new(:top_margin => 50) @pdf.draw_text "#{title}", :at => [@pdf.margin_box.left, @pdf.margin_box.top + 30] @max_dist = opts[:max_fret_distance] || Fingering::DEFAULT_MAX_FRET_DISTANCE if fingerings.empty? @pdf.text 'No fingerings found.' else @pdf.define_grid(:columns => 4, :rows => 6, :gutter => 40) fingerings.each_with_index do |f, i| print_fingering(f, i) end end if opts[:inline] @pdf.render else @pdf.render_file('chords.pdf') puts "Wrote chords.pdf" end end |