Class: Shellout::Query

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

Direct Known Subclasses

DateQuery

Instance Method Summary collapse

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

#callObject



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