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 18 19 20 |
# File 'lib/nginx_utils/logreader.rb', line 7 def initialize(log, ={}) @log = File.open(log) if [:parser] if [:parser].is_a? Regexp @format = :custom @parser = [:parser] else raise ArgumentError, "invalid argument" end else @format = [:format] || :ltsv end end |
Instance Method Details
#each ⇒ Object
22 23 24 25 26 |
# File 'lib/nginx_utils/logreader.rb', line 22 def each @log.each do |line| yield parse(line.chomp) end end |