Class: LogAuditor::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/log_auditor/reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_file) ⇒ Reader

Returns a new instance of Reader.



9
10
11
12
# File 'lib/log_auditor/reader.rb', line 9

def initialize(log_file)
  @log_file = log_file
  @data = []
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/log_auditor/reader.rb', line 7

def data
  @data
end

#log_fileObject (readonly)

Returns the value of attribute log_file.



6
7
8
# File 'lib/log_auditor/reader.rb', line 6

def log_file
  @log_file
end

Instance Method Details

#read!Object



14
15
16
17
18
19
20
# File 'lib/log_auditor/reader.rb', line 14

def read!
  raise LogAuditor::Errors::NoFileError unless File.exist?(log_file)

  @data = fetch_content
rescue Errno, TypeError
  raise LogAuditor::Errors::FileReadError
end