Class: Pyer::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/pyer/options.rb

Overview

Command class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, &block) ⇒ Command

Incapsulate internal command.

name - The String or Symbol command name. description - The String description text. block - An optional block.



269
270
271
272
273
274
# File 'lib/pyer/options.rb', line 269

def initialize(name, description, &block)
  @name = name.to_s
  fail InvalidCommandError, "Command #{@name} is invalid" if @name.start_with?('-')
  @description = description
  @callback = (block_given? ? block : nil)
end

Instance Attribute Details

#callbackObject (readonly)

Returns the value of attribute callback.



262
263
264
# File 'lib/pyer/options.rb', line 262

def callback
  @callback
end

#descriptionObject (readonly)

Returns the value of attribute description.



262
263
264
# File 'lib/pyer/options.rb', line 262

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



262
263
264
# File 'lib/pyer/options.rb', line 262

def name
  @name
end