Class: CTioga::Shortcut
- Inherits:
-
Object
- Object
- CTioga::Shortcut
- 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
-
#arguments ⇒ Object
Its arguments.
-
#name ⇒ Object
The name of the shortcut.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, *args) ⇒ Shortcut
constructor
A new instance of Shortcut.
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
#arguments ⇒ Object
Its arguments
28 29 30 |
# File 'lib/CTioga/shortcuts.rb', line 28 def arguments @arguments end |
#name ⇒ Object
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
40 41 42 |
# File 'lib/CTioga/shortcuts.rb', line 40 def self.has?(name) return @@shortcut_list.key?(name) end |
.list ⇒ Object
36 37 38 |
# File 'lib/CTioga/shortcuts.rb', line 36 def self.list return @@shortcut_list.keys end |
.pretty_print ⇒ Object
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 |