Class: TeRex::Format::ErrorFile

Inherits:
Object
  • Object
show all
Defined in:
lib/format/error_file.rb

Constant Summary collapse

@@csv_conf =
{:headers => true}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, klass) ⇒ ErrorFile

Returns a new instance of ErrorFile.



10
11
12
13
# File 'lib/format/error_file.rb', line 10

def initialize(file_path, klass)
  @path = file_path
  @category = klass
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



6
7
8
# File 'lib/format/error_file.rb', line 6

def category
  @category
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/format/error_file.rb', line 6

def path
  @path
end

#sentencesObject (readonly)

Returns the value of attribute sentences.



6
7
8
# File 'lib/format/error_file.rb', line 6

def sentences
  @sentences
end

Instance Method Details

#scannerObject

Each row of csv as Array object, strip it and return



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/format/error_file.rb', line 16

def scanner
  accumulator = []
  CSV.foreach(@path, @@csv_conf) do |row|
    next if row.empty?
    stripped_line = row[0].strip
    unless stripped_line.nil? || stripped_line.empty?
      accumulator << stripped_line
    end
  end
  @sentences ||= accumulator
end