Class: EZproxy::Log
- Inherits:
-
Object
- Object
- EZproxy::Log
- Defined in:
- lib/ezproxy/log.rb,
lib/ezproxy/log/format.rb
Defined Under Namespace
Classes: Format
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Log
constructor
A new instance of Log.
-
#parse_file(filename) ⇒ Object
Load and parse ‘filename`.
Constructor Details
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
3 4 5 |
# File 'lib/ezproxy/log.rb', line 3 def format @format end |
Instance Method Details
#parse_file(filename) ⇒ Object
Load and parse ‘filename`
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ezproxy/log.rb', line 10 def parse_file(filename) matcher = @format.to_regex defined_attributes = @format.defined_attributes File.open(filename) do |file| file.each_line do |line| m = line.match(matcher).to_a r = {} m[1..m.count].zip(defined_attributes).each do |match, attr| r[attr[:label]] = match end if block_given? yield r else r end end end end |