Class: ScaleGenerator::PNGFormatter

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

Overview

Formats a single fingering as png data

Instance Method Summary collapse

Constructor Details

#initialize(scale_hash, strings) ⇒ PNGFormatter

Returns a new instance of PNGFormatter.



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

def initialize(scale_hash, strings)
  @scale_hash = scale_hash
  @strings = strings
end

Instance Method Details



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/scale_generator/png_formatter.rb', line 13

def print(options={}, show_intervals = false)
  @label = options[:label]
  @show_intervals = show_intervals
  @frets = []
  
  @scale_hash.each do |key, val| 
    if key.is_a?(Numeric)
      @frets << val[:frets]
    end
  end
  
  @max_fret = @frets.flatten.max
  @min_fret = @frets.flatten.min
  @min_fret = 1 if @max_fret <= 4
  @number_of_frets = [@max_fret - @min_fret + 1, 4].max

  get_png_data
end