Class: NginxUtils::Logreader
- Inherits:
-
Object
- Object
- NginxUtils::Logreader
- Includes:
- Enumerable
- Defined in:
- lib/nginx_utils/logreader.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(log, options = {}) ⇒ Logreader
constructor
A new instance of Logreader.
Constructor Details
#initialize(log, options = {}) ⇒ Logreader
Returns a new instance of Logreader.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nginx_utils/logreader.rb', line 7 def initialize(log, ={}) @log = File.open(log) if [:parser] raise ArgumentError, "invalid argument" unless [:parser].is_a? Regexp @format = :custom @parser = [:parser] else @format = .fetch(:format, :ltsv) end end |
Instance Method Details
#each ⇒ Object
19 20 21 22 23 |
# File 'lib/nginx_utils/logreader.rb', line 19 def each @log.each do |line| yield parse(line.chomp) end end |