Class: RubyTapasDownloader::FeedFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_tapas_downloader/feed_fetcher.rb

Overview

Fetches feed from Ruby Tapas.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent, email, password) ⇒ FeedFetcher

Returns a new instance of FeedFetcher.



12
13
14
15
16
# File 'lib/ruby_tapas_downloader/feed_fetcher.rb', line 12

def initialize(agent, email, password)
  @agent    = agent
  @email    = email
  @password = password
end

Instance Attribute Details

#agentMechanize (readonly)

Returns the Mechanize agent.

Returns:

  • (Mechanize)

    the Mechanize agent.



4
5
6
# File 'lib/ruby_tapas_downloader/feed_fetcher.rb', line 4

def agent
  @agent
end

#emailString (readonly)

Returns the e-mail for the user.

Returns:

  • (String)

    the e-mail for the user.



7
8
9
# File 'lib/ruby_tapas_downloader/feed_fetcher.rb', line 7

def email
  @email
end

#passwordString (readonly)

Returns the password for the user.

Returns:

  • (String)

    the password for the user.



10
11
12
# File 'lib/ruby_tapas_downloader/feed_fetcher.rb', line 10

def password
  @password
end

Instance Method Details

#fetchRSS::Rss

Fetch feed from Ruby Tapas.

Returns:

  • (RSS::Rss)

    the feed for Ruby Tapas.



21
22
23
24
25
26
27
28
# File 'lib/ruby_tapas_downloader/feed_fetcher.rb', line 21

def fetch
  RubyTapasDownloader.logger.info 'Fetching episodes feed...'

  feed_url = RubyTapasDownloader::Config.urls[:feed]

  agent.add_auth feed_url, email, password
  RSS::Parser.parse agent.get(feed_url).body
end