Class: Spix::Parser::Feed
- Includes:
- DateTimeUtilities
- Defined in:
- lib/spix_parser/wrappers/feed.rb
Instance Method Summary collapse
- #feed_items ⇒ Object
- #feed_url ⇒ Object
-
#initialize(parsed_feed) ⇒ Feed
constructor
A new instance of Feed.
- #language ⇒ Object
- #site_url ⇒ Object
- #subtitle ⇒ Object
- #title ⇒ Object
- #uid ⇒ Object
- #updated_at ⇒ Object
- #url ⇒ Object
Methods included from DateTimeUtilities
Constructor Details
#initialize(parsed_feed) ⇒ Feed
Returns a new instance of Feed.
7 8 9 10 |
# File 'lib/spix_parser/wrappers/feed.rb', line 7 def initialize(parsed_feed) @feed = parsed_feed end |
Instance Method Details
#feed_items ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/spix_parser/wrappers/feed.rb', line 51 def feed_items #Se não for um feed válido, o accessor feed_entries não existe if @feed.respond_to?(:feed_entries) && @feed.feed_entries.present? @feed.feed_entries.map{|entry| Spix::Parser::FeedEntry.new(entry, self)} else [] end end |
#feed_url ⇒ Object
34 35 36 |
# File 'lib/spix_parser/wrappers/feed.rb', line 34 def feed_url @feed.feed_url end |
#language ⇒ Object
24 25 26 27 28 |
# File 'lib/spix_parser/wrappers/feed.rb', line 24 def language text = @feed.feed_language || "en" text = text.busk_normalize Sanitizer.sanitize(text) end |
#site_url ⇒ Object
30 31 32 |
# File 'lib/spix_parser/wrappers/feed.rb', line 30 def site_url @feed.url || extract_site_from_feed_url end |
#subtitle ⇒ Object
18 19 20 21 22 |
# File 'lib/spix_parser/wrappers/feed.rb', line 18 def subtitle text = @feed.feed_subtitle || "" text = text.busk_normalize Sanitizer.sanitize(text) end |
#title ⇒ Object
12 13 14 15 16 |
# File 'lib/spix_parser/wrappers/feed.rb', line 12 def title text = @feed.feed_title || "(title unknow)" text = text.busk_normalize Sanitizer.sanitize(text) end |
#uid ⇒ Object
42 43 44 |
# File 'lib/spix_parser/wrappers/feed.rb', line 42 def uid @feed.feed_url.to_sha1 end |
#updated_at ⇒ Object
46 47 48 49 |
# File 'lib/spix_parser/wrappers/feed.rb', line 46 def updated_at = @feed.last_modified || @feed.feed_entries.first.published_at || Time.now.utc build_datetime_object() end |
#url ⇒ Object
38 39 40 |
# File 'lib/spix_parser/wrappers/feed.rb', line 38 def url @feed.url end |