Class: GoApiClient::Atom::FeedPage
- Inherits:
-
Object
- Object
- GoApiClient::Atom::FeedPage
- Includes:
- Helpers::SimpleAttributesSupport
- Defined in:
- lib/go_api_client/atom/feed_page.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#next_page ⇒ Object
Returns the value of attribute next_page.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #contains_entry?(entry_or_id) ⇒ Boolean
- #entries_after(entry_or_id) ⇒ Object
-
#initialize(root, attributes = {}) ⇒ FeedPage
constructor
A new instance of FeedPage.
- #parse! ⇒ Object
Constructor Details
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
5 6 7 |
# File 'lib/go_api_client/atom/feed_page.rb', line 5 def entries @entries end |
#next_page ⇒ Object
Returns the value of attribute next_page.
5 6 7 |
# File 'lib/go_api_client/atom/feed_page.rb', line 5 def next_page @next_page end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/go_api_client/atom/feed_page.rb', line 5 def updated_at @updated_at end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/go_api_client/atom/feed_page.rb', line 5 def url @url end |
Instance Method Details
#contains_entry?(entry_or_id) ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'lib/go_api_client/atom/feed_page.rb', line 35 def contains_entry?(entry_or_id) if entry_or_id.is_a?(String) entries.find {|e| e.id == entry_or_id} else entries.include?(entry_or_id) end end |
#entries_after(entry_or_id) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/go_api_client/atom/feed_page.rb', line 25 def entries_after(entry_or_id) index = if entry_or_id.is_a?(String) entries.find_index {|e| e.id == entry_or_id} else entries.find_index {|e| e == entry_or_id} end index.zero? ? [] : entries[0..index-1] end |
#parse! ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/go_api_client/atom/feed_page.rb', line 14 def parse! self.updated_at = Time.parse(@root.xpath('xmlns:updated').first.content).utc self.next_page = href_from(@root.xpath("xmlns:link[@rel='next']")) self.url = href_from(@root.xpath("xmlns:link[@rel='self']")) self.entries = @root.xpath("xmlns:entry").collect do |entry| Entry.new(entry).parse! end @root = nil self end |