Class: FlickrSync::Prompt
- Inherits:
-
Object
- Object
- FlickrSync::Prompt
- Defined in:
- lib/flickr_sync/prompt.rb
Instance Method Summary collapse
- #answer(prompt, default = nil) ⇒ Object
- #ask(prompt, default) ⇒ Object
-
#initialize(inio, outio) ⇒ Prompt
constructor
A new instance of Prompt.
Constructor Details
#initialize(inio, outio) ⇒ Prompt
Returns a new instance of Prompt.
3 4 5 |
# File 'lib/flickr_sync/prompt.rb', line 3 def initialize inio, outio @inio, @outio = inio, outio end |
Instance Method Details
#answer(prompt, default = nil) ⇒ Object
14 15 16 17 |
# File 'lib/flickr_sync/prompt.rb', line 14 def answer prompt, default=nil @outio.print default ? "#{prompt} [#{default}] ? " : "#{prompt} ? " @inio.gets.chomp.strip end |
#ask(prompt, default) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/flickr_sync/prompt.rb', line 7 def ask prompt, default default_answer = default ? 'y' : 'n' response = answer prompt, default_answer response = default_answer if response.empty? response.start_with? 'y' end |