Class: AskService
- Inherits:
-
Object
- Object
- AskService
- Defined in:
- lib/ask_service.rb
Class Method Summary collapse
Class Method Details
.available? ⇒ Boolean
2 3 4 |
# File 'lib/ask_service.rb', line 2 def self.available? STDIN.tty? end |
.choose(label, options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ask_service.rb', line 6 def self.choose(label, ) result = .first printf "#{label} (#{.join(", ")}) [#{.first}]: " input = STDIN.gets.chomp result = input unless input.empty? unless .include?(result) puts "That wasn't one of the available options.".colorize(:red) + " Please try again." result = choose(label, ) end result end |