Class: Spix::Parser::FeedEntry

Inherits:
Object
  • Object
show all
Includes:
Memoizable, DateTimeUtilities
Defined in:
lib/spix_parser/wrappers/entry.rb

Instance Method Summary collapse

Methods included from DateTimeUtilities

#build_datetime_object

Constructor Details

#initialize(entry, feed) ⇒ FeedEntry

Returns a new instance of FeedEntry.



8
9
10
11
# File 'lib/spix_parser/wrappers/entry.rb', line 8

def initialize(entry, feed)
  @feed = feed
  @entry = entry
end

Instance Method Details

#authorObject



35
36
37
38
# File 'lib/spix_parser/wrappers/entry.rb', line 35

def author
  text = @entry. || ""
  Sanitizer.sanitize(text.busk_normalize)
end

#categoriesObject



72
73
74
75
76
# File 'lib/spix_parser/wrappers/entry.rb', line 72

def categories
  @entry.entry_categories.map do |category|
    Sanitizer.sanitize(category.busk_normalize)
  end
end

#contentObject



56
57
58
59
60
61
62
63
# File 'lib/spix_parser/wrappers/entry.rb', line 56

def content
  text = encoded_raw_content
  text = Sanitizer.strip_comments(text)
  text = Sanitizer.strip_disallowed_tags(text)
  text = Sanitizer.entities_to_chars(text)
  text = Spix::Utils.publisher_special_case :text => text, :url => @feed.url
  Spix::Utils.format_links({:text => text, :site_url => @feed.site_url})
end

#enclosuresObject



78
79
80
# File 'lib/spix_parser/wrappers/entry.rb', line 78

def enclosures
  @entry.entry_enclosures
end

#published_atObject



40
41
42
# File 'lib/spix_parser/wrappers/entry.rb', line 40

def published_at
  build_datetime_object(@entry.published) if @entry.published
end

#striped_contentObject



66
67
68
69
# File 'lib/spix_parser/wrappers/entry.rb', line 66

def striped_content
  text = encoded_raw_content
  Sanitizer.strip_tags(text)
end

#summaryObject



20
21
22
23
24
25
26
# File 'lib/spix_parser/wrappers/entry.rb', line 20

def summary
  text = @entry.entry_summary || ""
  text = text.busk_normalize
  text = Sanitizer.strip_comments(text)
  text = Sanitizer.strip_disallowed_tags(text)
  Sanitizer.entities_to_chars(text)
end

#titleObject



13
14
15
16
17
# File 'lib/spix_parser/wrappers/entry.rb', line 13

def title
  text = @entry.entry_title || "(title unknow)"
  text = text.busk_normalize
  Sanitizer.sanitize(text)
end

#uidObject



48
49
50
51
52
53
# File 'lib/spix_parser/wrappers/entry.rb', line 48

def uid
  uid = self.url || ""
  uid += encoded_raw_content_for :title
  uid += encoded_raw_content[0..25]
  uid.to_sha1
end

#updated_atObject



44
45
46
# File 'lib/spix_parser/wrappers/entry.rb', line 44

def updated_at
  build_datetime_object(@entry.updated) if @entry.updated
end

#urlObject



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

def url
  entry_url = @entry.entry_url || @feed.site_url
  RedirectFollower.resolve(entry_url).busk_normalize if entry_url.present?
end