Class: Herokulogs::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/herokulogs/cli.rb

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



3
4
5
6
7
8
9
# File 'lib/herokulogs/cli.rb', line 3

def initialize
  @formatter = Formatter.new(ARGV.first)
  @guard = Regexp.new(ARGV[1] || "")

  puts "herokulogs output format: #{@formatter.output_format.join(" ")}"
  puts "herokulogs guard: #{@guard.inspect}" if @guard != //
end

Instance Method Details

#run!Object



11
12
13
14
15
16
17
18
# File 'lib/herokulogs/cli.rb', line 11

def run!
  STDIN.each do |line|
    if line.match(@guard)
      formatted = @formatter.format(line.chomp)
      puts formatted if formatted
    end
  end
end