Sha256: 0d44f15f2b80d7d6b7179ac100f1fb8b0bbbcd5a2a163e47f9936ca36843c0b7

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

require 'readline'

module Clef

  class Console

    def run

      puts "Clef."
      puts "An algorithmic music language."
      puts "By T.J. VanSlyke."
      puts "\n"

      loop do
        begin
          line = Readline::readline('$>> ')

          if line.nil?
            puts "\nExiting..."
            exit
          end

          Readline::HISTORY.push(line)

          result = Clef.evaluate(line)

          if result.nil?
            puts "Clef didn't understand '#{line}': #{Clef.last_failure}"
          else
            puts "=> #{result.to_s}"
          end
        rescue => e
          puts "There was a system error:  #{e}"
        end
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
teejayvanslyke-clef-0.0.0 lib/clef/console.rb