Module: KtCmdLine
- Included in:
- KtCommon::ConsoleIO
- Defined in:
- lib/ktcommon/ktcmdline.rb
Overview
ktCmdLine.rb
Jeff McAffee 10/26/09
Purpose: Command Line helper methods
Instance Method Summary collapse
-
#getInput(text) ⇒ Object
Display a short message and collect input from the keyboard.
Instance Method Details
#getInput(text) ⇒ Object
Display a short message and collect input from the keyboard.
Accepts either an array of strings or a single string.
When the last array element is printed the cursor will
stay on the same line waiting for user input.
- text
-
string or array: text to display to user
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ktcommon/ktcmdline.rb', line 25 def getInput(text) lines = text *lines = text if text.class != Array text = lines.pop lines.each {|l| puts l } $stdout.write "#{text} " i = $stdin.readline i.chomp!.strip! return i end |