Class: GemMenu::Entry
- Inherits:
-
Object
- Object
- GemMenu::Entry
- Defined in:
- lib/gem_menu.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#next_method ⇒ Object
Returns the value of attribute next_method.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#previous ⇒ Object
Returns the value of attribute previous.
Instance Method Summary collapse
- #execute_selection(method) ⇒ Object
-
#initialize(name, next_method, optional_args = nil) ⇒ Entry
constructor
A new instance of Entry.
- #next_selection ⇒ Object
- #previous_selection ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, next_method, optional_args = nil) ⇒ Entry
Returns a new instance of Entry.
10 11 12 13 14 15 16 17 18 |
# File 'lib/gem_menu.rb', line 10 def initialize(name, next_method, optional_args=nil) self.name = name self.next_method = next_method if optional_args optional_args.each do |key, value| self.send("#{key}=", value) end end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/gem_menu.rb', line 8 def name @name end |
#next_method ⇒ Object
Returns the value of attribute next_method.
8 9 10 |
# File 'lib/gem_menu.rb', line 8 def next_method @next_method end |
#parameters ⇒ Object
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/gem_menu.rb', line 8 def parameters @parameters end |
#previous ⇒ Object
Returns the value of attribute previous.
8 9 10 |
# File 'lib/gem_menu.rb', line 8 def previous @previous end |
Instance Method Details
#execute_selection(method) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/gem_menu.rb', line 24 def execute_selection(method) if self.parameters method.call(self.parameters) else method.call end end |
#next_selection ⇒ Object
32 33 34 |
# File 'lib/gem_menu.rb', line 32 def next_selection execute_selection(self.next_method) end |
#previous_selection ⇒ Object
36 37 38 |
# File 'lib/gem_menu.rb', line 36 def previous_selection self.previous.call end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/gem_menu.rb', line 20 def to_s self.name end |