Class: GoogleDrive::SpreadSheet

Inherits:
Object
  • Object
show all
Defined in:
lib/spider_rails/specific/spread_sheet.rb

Instance Method Summary collapse

Instance Method Details

#transferObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spider_rails/specific/spread_sheet.rb', line 3

def transfer
  proxy = Net::HTTP.Proxy('127.0.0.1', 8087)
  session = GoogleDrive.("[email protected]", "zhuxingruo", proxy)

  ws = session.spreadsheet_by_key("0AiMMAt6U-_eEdFdNbXBfUjRMTlpsdV83OE9UWTRzTUE").worksheets[0]
  #ws[2, 1] = "BakaBaka"
  #ws[2, 2] = "Fuck you"
  Card.columns.each_with_index do |c, i|
    i = i + 1
    ws[1, i] = c.name
  end

  Card.all.each_with_index do |card, i|
    p "card.id:#{card.id}, i: #{i}"

    if card.id >= 869
      cf = card.attributes.each_with_index do |attr, j|
        j = j + 1
        #attr[0] is attr name, attr[1] is attr value
        ws[i, j] = attr[1]
      end

      ws.save()
      ws.reload()
    end
  end
end