Class: Webern::Formatters::BaseFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/webern/formatters/base_formatter.rb

Direct Known Subclasses

LilypondFormatter, PdfFormatter, TextFormatter

Constant Summary collapse

DEFAULT_OPTS =
{ show_pitches: true, path: '.' }
PITCH_CLASSES =
%w{ C C# D Eb E F F# G Ab A Bb B }

Instance Method Summary collapse

Constructor Details

#initialize(row, opts = {}) ⇒ BaseFormatter

Returns a new instance of BaseFormatter.



6
7
8
9
10
11
12
13
# File 'lib/webern/formatters/base_formatter.rb', line 6

def initialize(row, opts={})
  opts = DEFAULT_OPTS.merge(opts)
  @prime_row = row
  @show_pitches = opts[:show_pitches]
  @path = opts[:path].sub(/\/$/, '')
  @filename = opts[:filename] || 'row'
  @filepath = "#{@path}/#{@filename}"
end

Instance Method Details

#pitch_value(n) ⇒ Object



15
16
17
# File 'lib/webern/formatters/base_formatter.rb', line 15

def pitch_value(n)
  @show_pitches ? PITCH_CLASSES[n] : n.to_s
end