Class: Webbynode::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/webbynode/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Application

Returns a new instance of Application.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/webbynode/application.rb', line 7

def initialize(*args)
  args = ["help", "commands"] unless args.any?
  
  if args.first.include?(":")
    arg = args.shift
    args.unshift arg.split(":")[1]
    args.unshift arg.split(":")[0]
  end
  
  @command = args.shift
  @params = args
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



5
6
7
# File 'lib/webbynode/application.rb', line 5

def aliases
  @aliases
end

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/webbynode/application.rb', line 5

def command
  @command
end

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'lib/webbynode/application.rb', line 5

def params
  @params
end

Instance Method Details

#executeObject



20
21
22
23
24
25
# File 'lib/webbynode/application.rb', line 20

def execute
  if command_class = Webbynode::Command.for(command)
    cmd = command_class.new(*params)
    cmd.run
  end
end