Class: DiffColumns

Inherits:
Object
  • Object
show all
Defined in:
lib/coopy/diff_columns.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#change_rowObject

Returns the value of attribute change_row.



2
3
4
# File 'lib/coopy/diff_columns.rb', line 2

def change_row
  @change_row
end

#column_by_nameObject

Returns the value of attribute column_by_name.



8
9
10
# File 'lib/coopy/diff_columns.rb', line 8

def column_by_name
  @column_by_name
end

#column_by_offsetObject

Returns the value of attribute column_by_offset.



9
10
11
# File 'lib/coopy/diff_columns.rb', line 9

def column_by_offset
  @column_by_offset
end

#column_nameObject

general



6
7
8
# File 'lib/coopy/diff_columns.rb', line 6

def column_name
  @column_name
end

#column_offsetObject

after any column changes



7
8
9
# File 'lib/coopy/diff_columns.rb', line 7

def column_offset
  @column_offset
end

#title_rowObject

Returns the value of attribute title_row.



3
4
5
# File 'lib/coopy/diff_columns.rb', line 3

def title_row
  @title_row
end

Instance Method Details

#update(prefix = 1) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/coopy/diff_columns.rb', line 11

def update(prefix=1)
  return if @title_row.nil?
  @column_name = {}
  @column_offset = {}
  @column_by_name = {}
  @column_by_offset = []
  offset = -prefix
  @title_row.each_with_index do |title,idx|
    @column_name[idx] = title
    if offset>=0
      # assuming no column changes for the moment
      @column_offset[idx] = offset
      @column_by_name[title] = {
        :title => title,
        :in_offset => offset,
        :diff_offset => idx
      }
      @column_by_offset << @column_by_name[title]
    end
    offset = offset+1
  end
end