class Sheety::Cell
Constants
- COL_LETTERS
Attributes
col[R]
display_value[R]
input_value[R]
numeric_value[R]
row[R]
Public Instance Methods
as_batch_xml()
click to toggle source
# File lib/sheety/cell.rb, line 63 def as_batch_xml return [ "<entry>", "<batch:id>#{title}</batch:id>", "<batch:operation type=\"update\" />", "<id>#{id}</id>", "<link rel=\"#{LINK_EDIT}\" type=\"application/atom+xml\"", "href=\"#{link(LINK_EDIT)}\"/>", "<gs:cell row=\"#{@row}\" col=\"#{@col}\" inputValue=\"#{@input_value}\"/>", "</entry>", ].join(Sheety::NEWLINE) end
as_xml()
click to toggle source
# File lib/sheety/cell.rb, line 43 def as_xml return [ "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:gs=\"http://schemas.google.com/spreadsheets/2006\">", "<id>#{ if @id then @id else @parent.link(Sheety::Worksheet::LINK_CELLS) + "/#{rc}" end}</id>", "<link rel=\"#{Sheety::Feed::LINK_EDIT}\" type=\"application/atom+xml\" href=\"#{ if link(LINK_EDIT) then link(LINK_EDIT) else @parent.link(Sheety::Worksheet::LINK_CELLS) + "/#{rc}" end}\"/>", "<gs:cell row=\"#{row}\" col=\"#{col}\" inputValue=\"#{input_value}\"/>", "</entry>", ].join(Sheety::NEWLINE) end
col=(c)
click to toggle source
# File lib/sheety/cell.rb, line 27 def col=(c) if @col.nil? @col = c end end
inspect()
click to toggle source
# File lib/sheety/cell.rb, line 89 def inspect to_s end
parse(entry)
click to toggle source
Calls superclass method
Sheety::Feed#parse
# File lib/sheety/cell.rb, line 8 def parse(entry) super(entry) cell = entry['gs:cell'][0] @row = cell['row'].to_i @col = cell['col'].to_i @input_value = cell['inputValue'] @numeric_value = cell['numericValue'].to_f @display_value = cell['content'] end
rc()
click to toggle source
# File lib/sheety/cell.rb, line 39 def rc return "R#{row}C#{col}" end
row=(r)
click to toggle source
# File lib/sheety/cell.rb, line 33 def row=(r) if @row.nil? @row = r end end
save()
click to toggle source
# File lib/sheety/cell.rb, line 76 def save uri = link(LINK_EDIT) if uri return Sheety::Api.inst.put_feed(uri, as_xml) else return Sheety::Api.inst.post_feed(@parent.link(Sheety::Worksheet::LINK_CELLS), as_xml) end end
to_s()
click to toggle source
# File lib/sheety/cell.rb, line 85 def to_s "<#{self.class}::#{object_id} #{rc} input='#{input_value}' numeric='#{numeric_value}' display='#{display_value}'>" end
value=(new_value)
click to toggle source
# File lib/sheety/cell.rb, line 19 def value=(new_value) if new_value != @input_value @input_value = new_value @numeric_value = nil @display_value = nil end end