Class: RingCentral::RSS::AtomFeed

Inherits:
Object
  • Object
show all
Defined in:
lib/ringcentral-rss/atom_feed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil, opts = {}) ⇒ AtomFeed

Returns a new instance of AtomFeed.



8
9
10
11
12
13
14
15
16
# File 'lib/ringcentral-rss/atom_feed.rb', line 8

def initialize(response = nil, opts = {})
  if opts.key?(:feed_name) && opts[:feed_name]
    @feed_name = opts[:feed_name]
  else
    @feed_name = 'RingCentral Feed'
  end
  @feed = nil
  load_message_store_response(response) unless response.nil?
end

Instance Attribute Details

#feedObject

Returns the value of attribute feed.



6
7
8
# File 'lib/ringcentral-rss/atom_feed.rb', line 6

def feed
  @feed
end

Instance Method Details

#load_message_store_response(response) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/ringcentral-rss/atom_feed.rb', line 18

def load_message_store_response(response)
  @feed = Atom::Feed.new do |f|
    f.title = @feed_name
    f.links << Atom::Link.new(href: "#{response.body['uri']}")
    f.updated = Time.parse("#{response.headers['date']}")
    response.body['records'].each do |message|
      f.entries << RingCentral::RSS::AtomEntry.new(message).entry
    end
  end
end

#to_xmlObject



29
30
31
# File 'lib/ringcentral-rss/atom_feed.rb', line 29

def to_xml
  (!@feed.nil? && @feed.is_a?(Atom::Feed)) ? @feed.to_xml : nil
end