Sha256: 63c86e9d7c7aa5ed8739ce50841b4eed8a94fea2ccd1179b3a29dd12a87efb90
Contents?: true
Size: 737 Bytes
Versions: 3
Compression:
Stored size: 737 Bytes
Contents
# frozen_string_literal: true module Basic101 class Input def initialize(output, file = $stdout) @file = file @output = output @transcript = NullTranscript.new end def transcript=(transcript) @transcript = transcript end def read_line unless line = @file.gets @transcript.save_output "\n" echo "\n" raise NoMoreInputError, 'No more input' end @transcript.save_input line @transcript.save_output line echo line line.chomp end private def echo(s) return unless echo? @output.echo s end def isatty @file.isatty end def echo? !(isatty && @output.isatty) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
basic101-1.0.2 | lib/basic101/input.rb |
basic101-1.0.1 | lib/basic101/input.rb |
basic101-1.0.0 | lib/basic101/input.rb |