Class: Kontena::LightPrompt::Menu

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMenu

Returns a new instance of Menu.



14
15
16
17
# File 'lib/kontena/light_prompt.rb', line 14

def initialize
  @choices = []
  @calls = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



35
36
37
# File 'lib/kontena/light_prompt.rb', line 35

def method_missing(meth, *args)
  calls[meth] = args
end

Instance Attribute Details

#callsObject (readonly)

Returns the value of attribute calls.



12
13
14
# File 'lib/kontena/light_prompt.rb', line 12

def calls
  @calls
end

#choicesObject (readonly)

Returns the value of attribute choices.



12
13
14
# File 'lib/kontena/light_prompt.rb', line 12

def choices
  @choices
end

Instance Method Details

#add_quit_choiceObject



23
24
25
# File 'lib/kontena/light_prompt.rb', line 23

def add_quit_choice
  choice('(done)', :done)
end

#choice(text, label) ⇒ Object



19
20
21
# File 'lib/kontena/light_prompt.rb', line 19

def choice(text, label)
  choices << [text, label]
end

#remove_choice(value) ⇒ Object



27
28
29
# File 'lib/kontena/light_prompt.rb', line 27

def remove_choice(value)
  choices.reject! { |c| c.last == value }
end

#remove_choices(values) ⇒ Object



31
32
33
# File 'lib/kontena/light_prompt.rb', line 31

def remove_choices(values)
  values.each { |v| remove_choice(v) }
end

#respond_to_missing?(meth, privates = false) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/kontena/light_prompt.rb', line 39

def respond_to_missing?(meth, privates = false)
  prompt.respond_to?(meth, privates)
end