class Sheety::Feed

Constants

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
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

inspect() click to toggle source
# File lib/sheety/feed.rb, line 73
def inspect
  to_s
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