class Cloudit::Command::Base

Constants

DEFAULT_DIRECTORY
OPTION_NAME_OFFSET
VALID_METHODS

Attributes

parser[RW]
slop_opts[RW]

Public Class Methods

new(args=[]) click to toggle source
# 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

Public Instance Methods

execute() click to toggle source
# 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() click to toggle source
# File lib/cloudit/command/base.rb, line 38
def help
  $stdout.puts slop_opts
end
invalid_method() click to toggle source
# 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() click to toggle source
# File lib/cloudit/command/base.rb, line 42
def parser
  self.class.parser
end
slop_opts() click to toggle source
# File lib/cloudit/command/base.rb, line 46
def slop_opts
  self.class.slop_opts
end