Class: Jamming::PNGFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/jamming/png_formatter.rb

Overview

Formats a single fingering as png data

Instance Method Summary collapse

Constructor Details

#initialize(frets) ⇒ PNGFormatter

Returns a new instance of PNGFormatter.



8
9
10
11
# File 'lib/jamming/png_formatter.rb', line 8

def initialize(frets)
  @frets = frets
  @strings = ["E", "A", "D", "G", "B", "e"]
end

Instance Method Details



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jamming/png_formatter.rb', line 13

def print(options={})
  @label = options[:label]
  
  @max_fret = @frets.compact.max
  @min_fret = @frets.compact.delete_if { |f| f == 0 }.min
  @min_fret = 1 if @max_fret <= 4

  @number_of_frets = [@max_fret - @min_fret + 1, 4].max
  
  get_png_data
end