Class: CTioga::Shortcut

Inherits:
Object
  • Object
show all
Defined in:
lib/CTioga/shortcuts.rb

Overview

A class implementing small shortcuts, that is a set of command-line arguments.

Constant Summary collapse

@@shortcut_list =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *args) ⇒ Shortcut

Returns a new instance of Shortcut.



30
31
32
33
34
# File 'lib/CTioga/shortcuts.rb', line 30

def initialize(name, *args)
  @name = name
  @arguments = args
  @@shortcut_list[name] = self
end

Instance Attribute Details

#argumentsObject

Its arguments



28
29
30
# File 'lib/CTioga/shortcuts.rb', line 28

def arguments
  @arguments
end

#nameObject

The name of the shortcut



25
26
27
# File 'lib/CTioga/shortcuts.rb', line 25

def name
  @name
end

Class Method Details

.args(name) ⇒ Object



44
45
46
# File 'lib/CTioga/shortcuts.rb', line 44

def self.args(name)
  return @@shortcut_list[name].arguments
end

.has?(name) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/CTioga/shortcuts.rb', line 40

def self.has?(name)
  return @@shortcut_list.key?(name)
end

.listObject



36
37
38
# File 'lib/CTioga/shortcuts.rb', line 36

def self.list
  return @@shortcut_list.keys
end

.pretty_printObject



48
49
50
51
52
53
# File 'lib/CTioga/shortcuts.rb', line 48

def self.pretty_print
  for key in @@shortcut_list.keys.sort
    val = @@shortcut_list[key]
    puts "#{key}\t#{val.arguments.join(' ')}"
  end
end