Skip to content

Instantly share code, notes, and snippets.

@mhutter
Created March 12, 2017 20:45
Show Gist options
  • Save mhutter/ff54d0a9f41cdd94afa5a5d9a706c021 to your computer and use it in GitHub Desktop.
Save mhutter/ff54d0a9f41cdd94afa5a5d9a706c021 to your computer and use it in GitHub Desktop.
class Fyre
def initialize(klass)
@klass = klass
end
def call(method, *args)
method = method.to_sym
if method == :help
help
else
instance = @klass.new
puts instance.send(method, *args)
end
end
def help
puts "Usage: #{$0} <command>"
puts ""
puts "Commands:"
methods.each { |m| puts " #{m}" }
end
end
def methods
@klass.instance_methods - Object.instance_methods
end
def self.fyre(klass)
fi = Fyre.new(klass)
fi.call(*ARGV)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment