class Sheety::Feed
Constants
- LINK_ALT
- LINK_EDIT
- LINK_SELF
Attributes
content[R]
id[R]
parent[R]
title[RW]
updated[R]
Public Class Methods
new(parent, entry=nil)
click to toggle source
# File lib/sheety/feed.rb, line 14 def initialize(parent, entry=nil) @parent = parent @links = {} unless entry.nil? parse(entry) end end
Private Class Methods
deref(data, *keys)
click to toggle source
# File lib/sheety/feed.rb, line 79 def self.deref(data, *keys) found = data keys.each do |k| next if found.blank? found = found[k] end return found end
Public Instance Methods
as_xml()
click to toggle source
# File lib/sheety/feed.rb, line 36 def as_xml return "<entry></entry>" end
link(key)
click to toggle source
# File lib/sheety/feed.rb, line 32 def link(key) @links[key] end
parse(entry)
click to toggle source
# File lib/sheety/feed.rb, line 22 def parse(entry) return if entry.blank? || entry.length == 0 @title = Sheety::Feed.deref(entry, 'title', 0, 'content') @id = Sheety::Feed.deref(entry, 'id', 0) @content = Sheety::Feed.deref(entry, 'content', 'content') @updated = Sheety::Feed.deref(entry, 'updated', 0) @updated = DateTime.iso8601(@updated) if !@updated.blank? add_links(Sheety::Feed.deref(entry ,'link')) end
Protected Instance Methods
add_links(links)
click to toggle source
# File lib/sheety/feed.rb, line 42 def add_links(links) return if links.blank? return unless links.respond_to?(:each) # Conflict prevention is here to preserve original values parsed from the entities. # This mainly comes into play with the List Feed (a.k.a.: Rows) because we need the # ability to add new ones. links.each { |link_obj| @links[link_obj['rel']] = link_obj['href'] } end
inspect()
click to toggle source
# File lib/sheety/feed.rb, line 73 def inspect to_s end
link_add()
click to toggle source
# File lib/sheety/feed.rb, line 55 def link_add parent.link(parent.class::LINK_ADD) end
link_edit()
click to toggle source
# File lib/sheety/feed.rb, line 51 def link_edit link(LINK_EDIT) end
save()
click to toggle source
# File lib/sheety/feed.rb, line 59 def save result = if link_edit Sheety::Api.inst.put_feed(link_edit, as_xml) else Sheety::Api.inst.post_feed(link_add, as_xml) end parse(result) return result end
to_s()
click to toggle source
# File lib/sheety/feed.rb, line 69 def to_s "<#{self.class}::#{object_id}>" end