Class: TransmissionRSS::Feed
Instance Attribute Summary collapse
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #download_path(title = nil) ⇒ Object
-
#initialize(config = {}) ⇒ Feed
constructor
A new instance of Feed.
- #matches_regexp?(title) ⇒ Boolean
Constructor Details
#initialize(config = {}) ⇒ Feed
Returns a new instance of Feed.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/transmission-rss/feed.rb', line 5 def initialize(config = {}) @download_paths = {} case config when Hash @url = URI.encode(config['url'] || config.keys.first) @download_path = config['download_path'] matchers = Array(config['regexp']).map do |e| e.is_a?(String) ? e : e['matcher'] end @regexp = build_regexp(matchers) initialize_download_paths(config['regexp']) else @url = config.to_s end end |
Instance Attribute Details
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
3 4 5 |
# File 'lib/transmission-rss/feed.rb', line 3 def regexp @regexp end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/transmission-rss/feed.rb', line 3 def url @url end |
Instance Method Details
#download_path(title = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/transmission-rss/feed.rb', line 26 def download_path(title = nil) return @download_path if title.nil? @download_paths.each do |regexp, path| return path if title =~ to_regexp(regexp) end return @download_path end |
#matches_regexp?(title) ⇒ Boolean
36 37 38 |
# File 'lib/transmission-rss/feed.rb', line 36 def matches_regexp?(title) @regexp.nil? || !(title =~ @regexp).nil? end |