Class: NCSAParser::Log
- Inherits:
-
Object
- Object
- NCSAParser::Log
- Includes:
- Enumerable
- Defined in:
- lib/ncsa-parser/log.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(log, options = {}) ⇒ Log
constructor
A new instance of Log.
- #next_line ⇒ Object
Constructor Details
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
6 7 8 |
# File 'lib/ncsa-parser/log.rb', line 6 def log @log end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
6 7 8 |
# File 'lib/ncsa-parser/log.rb', line 6 def parser @parser end |
Class Method Details
.open(file, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ncsa-parser/log.rb', line 13 def self.open(file, = {}) file = if file.is_a?(String) File.open(file) else file end self.new(file, ) end |
Instance Method Details
#each ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ncsa-parser/log.rb', line 23 def each if block_given? self.log.each do |l| yield self.parser.parse_line(l) end else self.log.collect do |l| self.parser.parse_line(l) end end end |
#next_line ⇒ Object
35 36 37 38 39 |
# File 'lib/ncsa-parser/log.rb', line 35 def next_line self.parser.parse_line(self.log.gets).tap { |parsed| yield parsed if block_given? } end |