Skip to content

Instantly share code, notes, and snippets.

@dydx
Created January 16, 2010 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dydx/278549 to your computer and use it in GitHub Desktop.
Save dydx/278549 to your computer and use it in GitHub Desktop.
# unnecessary.rb - Josh Sandlin - 3:13PM - 1/15/2010
# An interpreter of the Unnecessary language
# raised when the source file is present
class CriticalError < Exception; end
# core of the interpreter
class Unnecessary
attr_accessor :source_file
def initialize( source_file )
@source_file = source_file
end
def parse
raise CriticalError, "The file exists!" unless !File.exists? @source_file
end
def execute
begin
parse
puts "Program executed successfully!"
rescue CriticalError => msg
puts "CRITICAL ERROR: #{msg}"
end
end
end
interpreter = Unnecessary.new( ARGV.shift )
interpreter.execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment