class Webern::Formatters::TextFormatter

Public Instance Methods

draw() click to toggle source
# File lib/webern/formatters/text_formatter.rb, line 4
def draw
  output($stdout)
end
write_to_file() click to toggle source
# File lib/webern/formatters/text_formatter.rb, line 9
def write_to_file
  File.open("#{@filepath}.txt", 'w') do |f|
    output(f)
  end
end

Private Instance Methods

border_row() click to toggle source
# File lib/webern/formatters/text_formatter.rb, line 27
def border_row; ('|---------' * 12) + "|\n"; end
empty_row() click to toggle source
# File lib/webern/formatters/text_formatter.rb, line 28
def empty_row; ('|         ' * 12) + "|\n"; end
output(target) click to toggle source
# File lib/webern/formatters/text_formatter.rb, line 17
def output(target)
  @prime_row.inversion.each do |i|
    target << border_row
    target << empty_row
    target << @prime_row.transpose(i).map{|n| pitch_cell(n) }.join + "|\n"
    target << empty_row
  end
  target << border_row
end
pitch_cell(n) click to toggle source
# File lib/webern/formatters/text_formatter.rb, line 29
def pitch_cell(n)
  '|   %s    ' % (pitch_value(n)).rjust(2)
end