Class: CloudyIntegrate::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudy_integrate/session.rb,
lib/cloudy_integrate/list_command.rb,
lib/cloudy_integrate/stop_command.rb,
lib/cloudy_integrate/start_command.rb

Overview

this class runs the top level garlic commands

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#verboseObject

Returns the value of attribute verbose.



5
6
7
# File 'lib/cloudy_integrate/session.rb', line 5

def verbose
  @verbose
end

Class Method Details

.call_command(id, *args) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
# File 'lib/cloudy_integrate/session.rb', line 29

def call_command(id, *args)
  meth = runner.method(id.to_sym)
  raise ArgumentError.new("Wrong number of arguments for #{meth.to_s}. Need #{meth.arity}}") unless meth.arity == args.size
  meth.call *args
end

.command_description(name) ⇒ Object



21
22
23
# File 'lib/cloudy_integrate/session.rb', line 21

def command_description(name)
  @@command_descriptions[name]
end

.commandsObject



25
26
27
# File 'lib/cloudy_integrate/session.rb', line 25

def commands
  @@command_descriptions.keys.map { |c| c.to_s}
end

.commands_with_descriptionObject



17
18
19
# File 'lib/cloudy_integrate/session.rb', line 17

def commands_with_description
  @@commands.map{ |m| [m, @@command_descriptions[m]]}
end

.define_command(name, desc, &block) ⇒ Object



11
12
13
14
15
# File 'lib/cloudy_integrate/session.rb', line 11

def define_command(name, desc, &block)
  @@commands << name
  @@command_descriptions[name] = desc
  define_method name, &block
end

.runnerObject



35
36
37
# File 'lib/cloudy_integrate/session.rb', line 35

def runner
  @runner ||= new
end