Class: TeRex::Format::ErrorFile
- Inherits:
-
Object
- Object
- TeRex::Format::ErrorFile
- Defined in:
- lib/format/error_file.rb
Constant Summary collapse
- @@csv_conf =
{:headers => true}
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sentences ⇒ Object
readonly
Returns the value of attribute sentences.
Instance Method Summary collapse
-
#initialize(file_path, klass) ⇒ ErrorFile
constructor
A new instance of ErrorFile.
-
#scanner ⇒ Object
Each row of csv as Array object, strip it and return.
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
#category ⇒ Object (readonly)
Returns the value of attribute category.
6 7 8 |
# File 'lib/format/error_file.rb', line 6 def category @category end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/format/error_file.rb', line 6 def path @path end |
#sentences ⇒ Object (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
#scanner ⇒ Object
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 |