Class: Brigit::Command

Inherits:
Object
  • Object
show all
Includes:
Fallible, Listable, Pretending
Defined in:
lib/brigit/commands/command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pretending

#pretend!

Methods included from Fallible

#fail

Methods included from Listable

included

Constructor Details

#initialize(*args) ⇒ Command

Returns a new instance of Command.



25
26
27
# File 'lib/brigit/commands/command.rb', line 25

def initialize(*args)
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



24
25
26
# File 'lib/brigit/commands/command.rb', line 24

def args
  @args
end

Class Method Details

.helpObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/brigit/commands/command.rb', line 13

def self.help
  @help ||= begin
    help_file = File.dirname(__FILE__) << "/../../../help/#{name}.rdoc"
    if File.file?(help_file)
      File.read(help_file) 
    else
      "Sorry, there is no documentation for this command."
    end
  end
end

Instance Method Details

#run {|parser| ... } ⇒ Object

Yields:

  • (parser)


29
30
31
32
# File 'lib/brigit/commands/command.rb', line 29

def run
  yield parser if block_given?
  parser.parse!(args)
end