Class: GoogleCells::Worksheet

Inherits:
GoogleObject show all
Includes:
Fetcher, Util
Defined in:
lib/google_cells/worksheet.rb

Defined Under Namespace

Classes: UpdateError

Constant Summary

Constants included from Fetcher

Fetcher::BASE_URL

Instance Method Summary collapse

Methods included from Util

#concat_url, #e

Methods included from Fetcher

#raw, #request

Methods inherited from GoogleObject

define_accessors, #initialize

Constructor Details

This class inherits a constructor from GoogleCells::GoogleObject

Instance Method Details

#rowsObject



12
13
14
# File 'lib/google_cells/worksheet.rb', line 12

def rows
  GoogleCells::CellSelector::RowSelector.new(self)
end

#save!Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/google_cells/worksheet.rb', line 16

def save!
  return if @changed_cells.nil? || @changed_cells.empty?
  batch_url = concat_url(cells_uri, "/batch")
  response = request(:post, batch_url, body: to_xml, headers:{
    "Content-Type" => "application/atom+xml", "If-Match" => "*"})
  doc = Nokogiri.parse(response.body)

  doc.css("atom|entry").each{|entry| check_entry_for_errors!(entry) }
  @changed_cells = {}
  true
end

#track_changes(cell) ⇒ Object



28
29
30
31
32
# File 'lib/google_cells/worksheet.rb', line 28

def track_changes(cell)
  @changed_cells ||= {}
  @changed_cells[cell.title] = cell # track only most recent change
  nil
end