Sha256: c020b45a11d7e4cefd79a191e91e0262b72dd51f25fb83afc5cdad38e8d7d047
Contents?: true
Size: 692 Bytes
Versions: 4
Compression:
Stored size: 692 Bytes
Contents
module BuildMaster class CommandInterface def initialize(io = SystemIo.new) @io = io end def puts(content) @io.puts(content) end def prompt(question) puts(question) gets end def prompt_for_choice(question, candidates) puts(question) 0.upto(candidates.size - 1) do |index| puts "[#{index + 1}] #{candidates[index]}" end answer = gets.to_i seletion = nil if answer > 0 && answer <= candidates.size selection = candidates[answer - 1] end return selection end def gets @io.gets end end class SystemIo def puts(content) $stdout.puts(content) end def gets $stdin.gets end end end
Version data entries
4 entries across 4 versions & 1 rubygems