Class: PRSS::Feed

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#uriObject (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

#downloaderObject



40
41
42
# File 'lib/prss/feed.rb', line 40

def downloader
  Downloader.new(links)
end


32
33
34
# File 'lib/prss/feed.rb', line 32

def links
  Links.new(output)
end

#outputObject



28
29
30
# File 'lib/prss/feed.rb', line 28

def output
  response
end

#responseObject



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