Module: OptimusPrime

Defined in:
lib/optimus_prime.rb,
lib/optimus_prime/optor.rb,
lib/optimus_prime/command.rb

Defined Under Namespace

Modules: ClassMethods Classes: Command, Optor

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/optimus_prime.rb', line 10

def self.included(klass)
  klass.class_eval do
    extend ClassMethods

    command :help do |cmd|
      ##
      # Show this help message
      if cmd and self.class.commands.include?(cmd)
        puts help(cmd)
      else
        puts "Commands:"
        puts self.class.commands.map { |name| "- #{name}" }
      end
    end

    def initialize
      self.class.init(self)
    end

    def help(name)
      self.class.help(name)
    end
  end
end