Module: Moses

Included in:
Application
Defined in:
lib/moses.rb

Defined Under Namespace

Modules: ClassMethods Classes: Application

Constant Summary collapse

VERSION_FILE =
'VERSION'
HELP_FILE =
'HELP'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/moses.rb', line 6

def args
  @args
end

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/moses.rb', line 6

def command
  @command
end

#default_commandObject (readonly)

Returns the value of attribute default_command.



6
7
8
# File 'lib/moses.rb', line 6

def default_command
  @default_command
end

#default_option_commandsObject (readonly)

Returns the value of attribute default_option_commands.



7
8
9
# File 'lib/moses.rb', line 7

def default_option_commands
  @default_option_commands
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/moses.rb', line 6

def options
  @options
end

Class Method Details

.included(base) ⇒ Object



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

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#default_commandsObject



43
44
45
# File 'lib/moses.rb', line 43

def default_commands
  @default_commands ||= [:help, :version]
end

#outputObject



39
40
41
# File 'lib/moses.rb', line 39

def output
  @output ||= $stdout
end

#runObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/moses.rb', line 56

def run
  @options = {}
  @args = Array.try_convert ARGV
  parse_options
  parse_command
  set_option_command

  self.send(@command) if valid_command?
  self.send(@default_command || :help) if @command.nil?
end