Class: CommandTree::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/command_tree/command.rb

Overview

A command class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, name, options = {}, &block) ⇒ Command

Returns a new instance of Command.



6
7
8
9
10
11
# File 'lib/command_tree/command.rb', line 6

def initialize(prefix, name, options = {}, &block)
  @prefix = prefix
  @name = name
  @desc = options[:desc]
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/command_tree/command.rb', line 4

def block
  @block
end

#descObject (readonly)

Returns the value of attribute desc.



4
5
6
# File 'lib/command_tree/command.rb', line 4

def desc
  @desc
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/command_tree/command.rb', line 4

def name
  @name
end

#prefixObject (readonly)

Returns the value of attribute prefix.



4
5
6
# File 'lib/command_tree/command.rb', line 4

def prefix
  @prefix
end

Instance Method Details

#executeObject



13
14
15
16
# File 'lib/command_tree/command.rb', line 13

def execute
  print_banner
  block.call
end