class Pondize::Convert
Constants
- ACCIDENTALS
- CIRCLE
- OCTAVES
Public Class Methods
new(key_signature, chars)
click to toggle source
# File lib/pondize/runner.rb, line 24 def initialize key_signature, chars @key_signature = key_signature @chars = chars end
Public Instance Methods
change_to()
click to toggle source
# File lib/pondize/runner.rb, line 46 def change_to if @key_signature > 0 return 's' end if @key_signature < 0 return 'f' end '' end
notes_to_change()
click to toggle source
# File lib/pondize/runner.rb, line 56 def notes_to_change if @key_signature > 0 return CIRCLE[0...@key_signature] end if @key_signature < 0 return CIRCLE[@key_signature..-1] end [] end
pondize(chars = nil)
click to toggle source
# File lib/pondize/runner.rb, line 29 def pondize chars = nil @chars = chars || @chars @chars.each_char .map .with_index { |char, index| (notes_to_change.include?(char) && !ACCIDENTALS.include?(@chars[index + 1]) ) ? "#{char}#{change_to}" : char } .map.with_index { |char, index| (ACCIDENTALS + OCTAVES).include?(@chars[index + 1]) ? char : "#{char} " } .join('') .gsub('n', '') .gsub(/ (\d)/, '\1') .gsub(/ -(\d)/, '-\1') .gsub('< <', '<<') .gsub('> >', '>>') .gsub(' .', '.') .gsub('l', 'f') .strip end