Class: RDialogy::InputMenu

Inherits:
Base
  • Object
show all
Defined in:
lib/rdialogy/inputmenu.rb

Class Method Summary collapse

Class Method Details

.args(options = {}) ⇒ Object

Formats the hash into an ordered list, valid options are:

  • :text - Title of the widget

  • :width

  • :height

  • :list_height - Number of items to display in the list

  • :items - Array of MenuItem



24
25
26
27
28
29
30
31
32
33
# File 'lib/rdialogy/inputmenu.rb', line 24

def self.args(options={})
  options[:items] ||= []
  options[:list_height] ||= options[:items].count * 3

  options[:items].map! do |item|
    [item.tag, item.item]
  end

  super + [options[:list_height]] + options[:items].flatten
end

.commandObject

Maps to the appropriate dialog argument



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

def self.command
  'inputmenu'
end

.run(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rdialogy/inputmenu.rb', line 7

def self.run(options={})
  super options, true do |input|
    if input =~ /^RENAMED/
      input.split(' ')[1..-1]
    else
      input.chomp
    end
  end
end