class Mailbot::CommandFactory
Public Class Methods
create(*args)
click to toggle source
@return [Mailbot::Commands::Base]
# File lib/mailbot/command_factory.rb, line 6 def self.create(*args) new(*args).create end
new(argv)
click to toggle source
@param argv [Array] ARGV
# File lib/mailbot/command_factory.rb, line 11 def initialize(argv) @argv = argv end
Public Instance Methods
create()
click to toggle source
@return [Mailbot::Commands::Base]
# File lib/mailbot/command_factory.rb, line 16 def create command_class.new @argv rescue Errors::CommandNotFound terminate end
Private Instance Methods
command_class()
click to toggle source
# File lib/mailbot/command_factory.rb, line 24 def command_class case command_name when "sync" Commands::Sync when "list" Commands::List else raise Errors::CommandNotFound end end
command_name()
click to toggle source
# File lib/mailbot/command_factory.rb, line 35 def command_name @argv[0] end
terminate()
click to toggle source
# File lib/mailbot/command_factory.rb, line 43 def terminate warn usage exit 1 end
usage()
click to toggle source
# File lib/mailbot/command_factory.rb, line 39 def usage "Usage: #{$0} <command> [options]" end