Class: Spix::Parser::Feed

Inherits:
Object show all
Includes:
DateTimeUtilities
Defined in:
lib/spix_parser/wrappers/feed.rb

Instance Method Summary collapse

Methods included from DateTimeUtilities

#build_datetime_object

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

Instance Method Details

#feed_itemsObject



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_urlObject



34
35
36
# File 'lib/spix_parser/wrappers/feed.rb', line 34

def feed_url
  @feed.feed_url
end

#languageObject



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_urlObject



30
31
32
# File 'lib/spix_parser/wrappers/feed.rb', line 30

def site_url
  @feed.url || extract_site_from_feed_url
end

#subtitleObject



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

#titleObject



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

#uidObject



42
43
44
# File 'lib/spix_parser/wrappers/feed.rb', line 42

def uid
  @feed.feed_url.to_sha1
end

#updated_atObject



46
47
48
49
# File 'lib/spix_parser/wrappers/feed.rb', line 46

def updated_at
  timestamp = @feed.last_modified || @feed.feed_entries.first.published_at || Time.now.utc
  build_datetime_object(timestamp)
end

#urlObject



38
39
40
# File 'lib/spix_parser/wrappers/feed.rb', line 38

def url
  @feed.url
end