Class: Rssly::Article
- Inherits:
-
Object
- Object
- Rssly::Article
- Defined in:
- lib/rssly/article.rb
Overview
Represents a single rss article
Instance Attribute Summary collapse
-
#published ⇒ Object
Returns the value of attribute published.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
-
#topics ⇒ Object
Returns the value of attribute topics.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #extracted ⇒ Object
-
#initialize(title: nil, url: nil, published: nil, summary: nil, topics: nil) ⇒ Article
constructor
A new instance of Article.
- #summarized ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(title: nil, url: nil, published: nil, summary: nil, topics: nil) ⇒ Article
Returns a new instance of Article.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rssly/article.rb', line 22 def initialize(title: nil, url: nil, published: nil, summary: nil, topics: nil) self.title = title self.url = url self.published = published self.summary = summary self.topics = topics end |
Instance Attribute Details
#published ⇒ Object
Returns the value of attribute published.
20 21 22 |
# File 'lib/rssly/article.rb', line 20 def published @published end |
#summary ⇒ Object
Returns the value of attribute summary.
18 19 20 |
# File 'lib/rssly/article.rb', line 18 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
16 17 18 |
# File 'lib/rssly/article.rb', line 16 def title @title end |
#topics ⇒ Object
Returns the value of attribute topics.
19 20 21 |
# File 'lib/rssly/article.rb', line 19 def topics @topics end |
#url ⇒ Object
Returns the value of attribute url.
17 18 19 |
# File 'lib/rssly/article.rb', line 17 def url @url end |
Class Method Details
.create_from_feedjira_entry(entry) ⇒ Object
11 12 13 |
# File 'lib/rssly/article.rb', line 11 def create_from_feedjira_entry(entry) new(title: entry.title, url: entry.url, published: entry.published) end |
Instance Method Details
#extracted ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rssly/article.rb', line 75 def extracted @extracted ||= begin $stderr.puts "Fetching article at #{url}" if Rssly::CONFIG[:verbose] source = open(url, allow_redirections: :all).read Readability::Document.new(source) end rescue raise \ Rssly::HTTPError, "Could not retrieve document for article at: #{url}" end |
#summarized ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/rssly/article.rb', line 67 def summarized @summarized ||= begin $stderr.puts "Summarizing article at #{url}" if Rssly::CONFIG[:verbose] text = extracted.content.gsub(/<\/?[^>]*>/, '') OTS.parse(text) end end |
#to_h ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/rssly/article.rb', line 59 def to_h { title: title, url: url, summary: summary, topics: topics, published: published } end |