Class: Shellout::Query
- Inherits:
-
Object
- Object
- Shellout::Query
- Defined in:
- lib/shellout/query.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(question = '', default = nil) ⇒ Query
constructor
A new instance of Query.
- #io=(io) ⇒ Object
Constructor Details
#initialize(question = '', default = nil) ⇒ Query
Returns a new instance of Query.
6 7 8 9 10 |
# File 'lib/shellout/query.rb', line 6 def initialize(question='', default=nil) @question = question + (default.nil? ? '' : " [#{default}]") @default = default @io = Readline end |
Instance Method Details
#call ⇒ Object
16 17 18 19 |
# File 'lib/shellout/query.rb', line 16 def call answer = ask return answer == '' ? @default : answer end |
#io=(io) ⇒ Object
12 13 14 |
# File 'lib/shellout/query.rb', line 12 def io=(io) @io = io end |