Class: Alicorn::LogParser

Inherits:
Object
  • Object
show all
Defined in:
lib/alicorn/log_parser.rb

Constant Summary collapse

SAMPLE_REGEX =
/(?<sample_type>active|queued|calling|writing):\[(?<values>.+)\]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = "alicorn.log") ⇒ LogParser

Returns a new instance of LogParser.



7
8
9
10
# File 'lib/alicorn/log_parser.rb', line 7

def initialize(file = "alicorn.log")
  self.filename = file
  self.samples  = []
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



3
4
5
# File 'lib/alicorn/log_parser.rb', line 3

def filename
  @filename
end

#samplesObject

Returns the value of attribute samples.



3
4
5
# File 'lib/alicorn/log_parser.rb', line 3

def samples
  @samples
end

Instance Method Details

#parseObject



12
13
14
15
16
17
18
# File 'lib/alicorn/log_parser.rb', line 12

def parse
  f = File.open(filename)
  f.each do |line|
    sample_line(line)
  end
  samples
end