Class: Sheety::Cell
Constant Summary collapse
- COL_LETTERS =
[nil, *('A'..'Z')]
Constants inherited from Feed
Feed::LINK_ALT, Feed::LINK_EDIT, Feed::LINK_SELF
Instance Attribute Summary collapse
-
#col ⇒ Object
Returns the value of attribute col.
-
#display_value ⇒ Object
readonly
Returns the value of attribute display_value.
-
#input_value ⇒ Object
readonly
Returns the value of attribute input_value.
-
#numeric_value ⇒ Object
readonly
Returns the value of attribute numeric_value.
-
#row ⇒ Object
Returns the value of attribute row.
Attributes inherited from Feed
#content, #id, #parent, #title, #updated
Instance Method Summary collapse
- #as_batch_xml ⇒ Object
- #as_xml ⇒ Object
- #inspect ⇒ Object
- #parse(entry) ⇒ Object
- #rc ⇒ Object
- #save ⇒ Object
- #to_s ⇒ Object
- #value=(new_value) ⇒ Object
Methods inherited from Feed
Methods included from Children
#_get_i_val, #_passes_constraint, included
Constructor Details
This class inherits a constructor from Sheety::Feed
Instance Attribute Details
#col ⇒ Object
Returns the value of attribute col.
6 7 8 |
# File 'lib/sheety/cell.rb', line 6 def col @col end |
#display_value ⇒ Object (readonly)
Returns the value of attribute display_value.
6 7 8 |
# File 'lib/sheety/cell.rb', line 6 def display_value @display_value end |
#input_value ⇒ Object (readonly)
Returns the value of attribute input_value.
6 7 8 |
# File 'lib/sheety/cell.rb', line 6 def input_value @input_value end |
#numeric_value ⇒ Object (readonly)
Returns the value of attribute numeric_value.
6 7 8 |
# File 'lib/sheety/cell.rb', line 6 def numeric_value @numeric_value end |
#row ⇒ Object
Returns the value of attribute row.
6 7 8 |
# File 'lib/sheety/cell.rb', line 6 def row @row end |
Instance Method Details
#as_batch_xml ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 |
#inspect ⇒ Object
89 90 91 |
# File 'lib/sheety/cell.rb', line 89 def inspect to_s end |
#parse(entry) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# 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 ⇒ Object
39 40 41 |
# File 'lib/sheety/cell.rb', line 39 def rc return "R#{row}C#{col}" end |
#save ⇒ Object
76 77 78 79 80 81 82 83 |
# 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 ⇒ Object
85 86 87 |
# 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) ⇒ Object
19 20 21 22 23 24 25 |
# 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 |