Class: CSVDiff::Algorithm::Diff
- Inherits:
-
Object
- Object
- CSVDiff::Algorithm::Diff
- Defined in:
- lib/csv-diff/algorithm.rb
Overview
Holds the details of a single difference
Instance Attribute Summary collapse
-
#diff_type ⇒ Object
Returns the value of attribute diff_type.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
-
#sibling_position ⇒ Object
Returns the value of attribute sibling_position.
Instance Method Summary collapse
-
#[](key) ⇒ Object
For backwards compatibility and access to fields with differences.
-
#initialize(diff_type, fields, row_idx, pos_idx) ⇒ Diff
constructor
A new instance of Diff.
Constructor Details
#initialize(diff_type, fields, row_idx, pos_idx) ⇒ Diff
14 15 16 17 18 19 |
# File 'lib/csv-diff/algorithm.rb', line 14 def initialize(diff_type, fields, row_idx, pos_idx) @diff_type = diff_type @fields = fields @row = row_idx + 1 self.sibling_position = pos_idx end |
Instance Attribute Details
#diff_type ⇒ Object
Returns the value of attribute diff_type.
9 10 11 |
# File 'lib/csv-diff/algorithm.rb', line 9 def diff_type @diff_type end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
10 11 12 |
# File 'lib/csv-diff/algorithm.rb', line 10 def fields @fields end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
11 12 13 |
# File 'lib/csv-diff/algorithm.rb', line 11 def row @row end |
#sibling_position ⇒ Object
Returns the value of attribute sibling_position.
12 13 14 |
# File 'lib/csv-diff/algorithm.rb', line 12 def sibling_position @sibling_position end |
Instance Method Details
#[](key) ⇒ Object
For backwards compatibility and access to fields with differences
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/csv-diff/algorithm.rb', line 37 def [](key) case key when :action a = diff_type.to_s a[0] = a[0].upcase a when :row @row when :sibling_position @sibling_position else @fields[key] end end |