Method: ICharger::Log::File#initialize

Defined in:
lib/icharger/log/file.rb

#initialize(uri) ⇒ File

Returns a new instance of File.



18
19
20
21
22
23
24
25
# File 'lib/icharger/log/file.rb', line 18

def initialize(uri)
  open(uri, 'r') do |file|
    @rows = file.readlines.map { |row| ICharger::Log::Row.new(row) }
  end
  raise ArgumentError, 'No records found in file' if @rows.empty?
rescue => e
  raise ArgumentError, "File does not appear to be an iCharger log (#{e})"
end