Class: DS::Converter::Writer
- Inherits:
-
Object
- Object
- DS::Converter::Writer
- Defined in:
- lib/ds/converter/writer.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Instance Method Summary collapse
- #add_error(row_num, error) ⇒ Object
- #errors ⇒ Object
- #initializer(output_io, row_validator) ⇒ Object
- #valid? ⇒ Boolean
- #validate_row(row_num, row) ⇒ Object
- #write ⇒ Object
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
7 8 9 |
# File 'lib/ds/converter/writer.rb', line 7 def count @count end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
8 9 10 |
# File 'lib/ds/converter/writer.rb', line 8 def output @output end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
9 10 11 |
# File 'lib/ds/converter/writer.rb', line 9 def validator @validator end |
Instance Method Details
#add_error(row_num, error) ⇒ Object
41 42 43 |
# File 'lib/ds/converter/writer.rb', line 41 def add_error row_num, error @errors << [row_num, error] end |
#errors ⇒ Object
45 46 47 |
# File 'lib/ds/converter/writer.rb', line 45 def errors @errors.dup end |
#initializer(output_io, row_validator) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ds/converter/writer.rb', line 12 def initializer output_io, row_validator @output = output_io @count = 1 @validator = row_validator @valid = true @errors = [] end |
#valid? ⇒ Boolean
31 32 33 |
# File 'lib/ds/converter/writer.rb', line 31 def valid? errors.blank? end |
#validate_row(row_num, row) ⇒ Object
35 36 37 38 39 |
# File 'lib/ds/converter/writer.rb', line 35 def validate_row row_num, row error = validator.row_valid? row return unless row add_error row_num, error end |