Class: GemMenu::Entry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/gem_menu.rb', line 8

def name
  @name
end

#next_methodObject

Returns the value of attribute next_method.



8
9
10
# File 'lib/gem_menu.rb', line 8

def next_method
  @next_method
end

#parametersObject

Returns the value of attribute parameters.



8
9
10
# File 'lib/gem_menu.rb', line 8

def parameters
  @parameters
end

#previousObject

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_selectionObject



32
33
34
# File 'lib/gem_menu.rb', line 32

def next_selection
    execute_selection(self.next_method)
end

#previous_selectionObject



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

def previous_selection
    self.previous.call
end

#to_sObject



20
21
22
# File 'lib/gem_menu.rb', line 20

def to_s
    self.name
end