Created
March 12, 2017 20:45
-
-
Save mhutter/ff54d0a9f41cdd94afa5a5d9a706c021 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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