Class: PRSS::Feed
- Inherits:
-
Object
- Object
- PRSS::Feed
- Defined in:
- lib/prss/feed.rb
Constant Summary collapse
- PERSONAL_FEED_URL =
ENV.fetch('PRSS_FEED_URL') { 'https://hdbits.org/rss/my'.freeze }
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #download_to(output) ⇒ Object
- #downloader ⇒ Object
-
#initialize(passkey) ⇒ Feed
constructor
A new instance of Feed.
- #links ⇒ Object
- #output ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(passkey) ⇒ Feed
Returns a new instance of Feed.
11 12 13 14 15 16 |
# File 'lib/prss/feed.rb', line 11 def initialize(passkey) #@passkey = passkey @uri = URI(PERSONAL_FEED_URL) @uri.query = "passkey=#{passkey}" @uri.freeze end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/prss/feed.rb', line 9 def uri @uri end |
Instance Method Details
#download_to(output) ⇒ Object
36 37 38 |
# File 'lib/prss/feed.rb', line 36 def download_to(output) downloader.download_to(output) end |
#downloader ⇒ Object
40 41 42 |
# File 'lib/prss/feed.rb', line 40 def downloader Downloader.new(links) end |
#links ⇒ Object
32 33 34 |
# File 'lib/prss/feed.rb', line 32 def links Links.new(output) end |
#output ⇒ Object
28 29 30 |
# File 'lib/prss/feed.rb', line 28 def output response end |
#response ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/prss/feed.rb', line 18 def response response = nil time = Benchmark.realtime do response = Net::HTTP.get(@uri) end puts "Fetched #{@uri} in #{time.round(2)}s" response end |