Class: LogErrorHandler::StdinReader
- Inherits:
-
Object
- Object
- LogErrorHandler::StdinReader
- Defined in:
- lib/log_error_handler/stdin_reader.rb
Constant Summary collapse
- TMP_DIR_NAME =
'log_error_handler'.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tracker) ⇒ StdinReader
constructor
A new instance of StdinReader.
- #start ⇒ Object
Constructor Details
#initialize(tracker) ⇒ StdinReader
Returns a new instance of StdinReader.
5 6 7 |
# File 'lib/log_error_handler/stdin_reader.rb', line 5 def initialize(tracker) @tracker = tracker end |
Class Method Details
.start(tracker) ⇒ Object
9 10 11 12 13 |
# File 'lib/log_error_handler/stdin_reader.rb', line 9 def self.start(tracker) stdin_reader = new(tracker) stdin_reader.start stdin_reader end |
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/log_error_handler/stdin_reader.rb', line 15 def start Dir.mkdir("/tmp/#{TMP_DIR_NAME}") unless Dir.exist?("/tmp/#{TMP_DIR_NAME}") $stdout.puts 'Starting read input data...' if @tracker.[:debug_mode] $stdin.each do |line| tid = line[@tracker.[:tid_regexp]] @last_tid = tid || @last_tid write_to_file(line) if @last_tid end end |