Class: LogAnalyser::Parser
- Inherits:
-
Object
- Object
- LogAnalyser::Parser
- Defined in:
- lib/parser.rb
Defined Under Namespace
Classes: FileNotFoundError
Class Method Summary collapse
Instance Method Summary collapse
- #call(file_path) ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
15 16 17 |
# File 'lib/parser.rb', line 15 def initialize @entries = Hash.new { |h, k| h[k] = [] } end |
Class Method Details
.call(file_path) ⇒ Object
11 12 13 |
# File 'lib/parser.rb', line 11 def self.call(file_path) new.call(file_path) end |
Instance Method Details
#call(file_path) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/parser.rb', line 19 def call(file_path) raise FileNotFoundError, file_path unless File.exist?(file_path) data = File.open(file_path).map(&:strip) data.reject!(&:empty?) parse(data) entries end |