Class: Squiggle::ChunkParser
- Inherits:
-
Object
- Object
- Squiggle::ChunkParser
- Defined in:
- lib/squiggle/chunk_parser.rb
Instance Method Summary collapse
- #current_line ⇒ Object
- #has_lines? ⇒ Boolean
-
#initialize(chunk, options = {}) ⇒ ChunkParser
constructor
A new instance of ChunkParser.
- #next_line ⇒ Object
Constructor Details
#initialize(chunk, options = {}) ⇒ ChunkParser
Returns a new instance of ChunkParser.
3 4 5 6 7 8 9 |
# File 'lib/squiggle/chunk_parser.rb', line 3 def initialize(chunk, = {}) [:parser] = SquidStandardParser @parser = [:parser].new([:time_zone]) @lines = chunk.split("\n").select { |e| e.length > 5 } @current_line = next_line Rails.logger.info("Chunk Parser received: #{@lines.size} lines") end |
Instance Method Details
#current_line ⇒ Object
15 16 17 |
# File 'lib/squiggle/chunk_parser.rb', line 15 def current_line @current_line end |
#has_lines? ⇒ Boolean
11 12 13 |
# File 'lib/squiggle/chunk_parser.rb', line 11 def has_lines? !@lines.empty? end |
#next_line ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/squiggle/chunk_parser.rb', line 19 def next_line return nil if @lines.empty? to_parse = @lines.shift logline = @parser.parse(to_parse) if logline.invalid? #STDERR.puts "Line is INVALID" logline = self.next_line # recurse end @current_line = logline end |