@@ -47,8 +47,13 @@ def padding=(value)
47
47
#
48
48
def ask ( statement , *args )
49
49
options = args . last . is_a? ( Hash ) ? args . pop : { }
50
+ color = args . first
50
51
51
- options [ :limited_to ] ? ask_filtered ( statement , options , *args ) : ask_simply ( statement , options , *args )
52
+ if options [ :limited_to ]
53
+ ask_filtered ( statement , color , options )
54
+ else
55
+ ask_simply ( statement , color , options )
56
+ end
52
57
end
53
58
54
59
# Say (print) something to the user. If the sentence ends with a whitespace
@@ -372,7 +377,7 @@ def as_unicode
372
377
end
373
378
end
374
379
375
- def ask_simply ( statement , options = { } , color = nil )
380
+ def ask_simply ( statement , color , options )
376
381
default = options [ :default ]
377
382
message = [ statement , ( "(#{ default . inspect } )" if default ) , nil ] . uniq . join ( " " )
378
383
say ( message , color )
@@ -389,11 +394,11 @@ def ask_simply(statement, options = {}, color=nil)
389
394
end
390
395
end
391
396
392
- def ask_filtered ( statement , options = { } , * args )
397
+ def ask_filtered ( statement , color , options )
393
398
answer_set = options [ :limited_to ]
394
399
correct_answer = nil
395
400
until correct_answer
396
- answer = ask_simply ( "#{ statement } #{ answer_set . inspect } " , options , * args )
401
+ answer = ask_simply ( "#{ statement } #{ answer_set . inspect } " , color , options )
397
402
correct_answer = answer_set . include? ( answer ) ? answer : nil
398
403
answers = answer_set . map ( &:inspect ) . join ( ", " )
399
404
say ( "Your response must be one of: [#{ answers } ]. Please try again." ) unless correct_answer
0 commit comments