Class: Perquackey::Application
- Inherits:
-
Object
- Object
- Perquackey::Application
- Defined in:
- lib/perquackey/application.rb
Class Method Summary collapse
-
.run!(argv) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #run!(argv) ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/perquackey/application.rb', line 9 def initialize = OptionParser.with_defaults do |opts| opts. = "Usage: #{File.basename($0)} [-c|-s]" opts.defaults = %w(--console) opts.version = Perquackey::VERSION opts.separator '' opts.on('-c', '--console', 'Run an interactive console.') do @mode = :console end opts.on('-s', '--server[=port]', 'Run an http server.') do |port| @mode = :server @port = port || 3000 end end end |
Class Method Details
.run!(argv) ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/perquackey/application.rb', line 5 def self.run!(argv) #:nodoc: new.run!(argv) end |
Instance Method Details
#run!(argv) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/perquackey/application.rb', line 27 def run!(argv) .order(argv) case @mode when :console Perquackey::Console.run! when :server Perquackey::Server.run!(:port => @port) end end |