Class: GdocTransWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/transync/gdoc_trans/gdoc_trans_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ GdocTransWriter

Returns a new instance of GdocTransWriter.



7
8
9
# File 'lib/transync/gdoc_trans/gdoc_trans_writer.rb', line 7

def initialize(worksheet)
  @worksheet = worksheet
end

Instance Attribute Details

#worksheetObject

Returns the value of attribute worksheet.



5
6
7
# File 'lib/transync/gdoc_trans/gdoc_trans_writer.rb', line 5

def worksheet
  @worksheet
end

Instance Method Details

#shift_up(old_row_num, rows_count) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/transync/gdoc_trans/gdoc_trans_writer.rb', line 15

def shift_up(old_row_num, rows_count)
  # shift up that many times we're missing till the end
  (old_row_num..rows_count).to_a.each do |new_row|
    (1..worksheet.num_cols).to_a.each do |col|
      cell = @worksheet[new_row, col]
      @worksheet[new_row, col] = ''
      @worksheet[new_row + 1, col] = cell
    end
  end

  @worksheet
end

#write(row, column, data) ⇒ Object



11
12
13
# File 'lib/transync/gdoc_trans/gdoc_trans_writer.rb', line 11

def write(row, column, data)
  @worksheet[row, GdocTrans::WORKSHEET_COLUMNS[column.to_sym]] = data
end