Class: Cloudit::Command::Base
- Inherits:
-
Object
- Object
- Cloudit::Command::Base
show all
- Defined in:
- lib/cloudit/command/base.rb
Constant Summary
collapse
- VALID_METHODS =
[]
- OPTION_NAME_OFFSET =
6
- DEFAULT_DIRECTORY =
'./'
Class Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args = []) ⇒ Base
Returns a new instance of Base.
13
14
15
16
17
18
19
20
|
# File 'lib/cloudit/command/base.rb', line 13
def initialize(args=[])
@method = if args[0].is_a?(String) && args[0].include?('-')
nil
else
args.shift.strip rescue nil
end
@opts = parser.parse(args)
end
|
Class Attribute Details
.parser ⇒ Object
Returns the value of attribute parser.
6
7
8
|
# File 'lib/cloudit/command/base.rb', line 6
def parser
@parser
end
|
.slop_opts ⇒ Object
Returns the value of attribute slop_opts.
6
7
8
|
# File 'lib/cloudit/command/base.rb', line 6
def slop_opts
@slop_opts
end
|
Instance Method Details
#execute ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/cloudit/command/base.rb', line 22
def execute
puts @method
if @method.nil?
index
elsif self.class::VALID_METHODS.include?(@method)
self.send(@method)
else
invalid_method
end
end
|
#help ⇒ Object
38
39
40
|
# File 'lib/cloudit/command/base.rb', line 38
def help
$stdout.puts slop_opts
end
|
#invalid_method ⇒ Object
34
35
36
|
# File 'lib/cloudit/command/base.rb', line 34
def invalid_method
$stdout.puts "cloudit: '#{@method}' is not a cloudit command\nSee 'cloudit --help'"
end
|
#parser ⇒ Object
42
43
44
|
# File 'lib/cloudit/command/base.rb', line 42
def parser
self.class.parser
end
|
#slop_opts ⇒ Object
46
47
48
|
# File 'lib/cloudit/command/base.rb', line 46
def slop_opts
self.class.slop_opts
end
|