Class: Feedzirra::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/feedzirra/reader.rb

Overview

Class Reader is an experimental interface for fetching and parsing Feed objects, using pluggable and (optionally) persistent backends to maintain state for fetched feeds.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Reader

Returns a new instance of Reader.



9
10
11
12
# File 'lib/feedzirra/reader.rb', line 9

def initialize(*args)
  @options  = args.extract_options!
  @urls     = args.flatten
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/feedzirra/reader.rb', line 7

def options
  @options
end

#urlsObject (readonly)

Returns the value of attribute urls.



7
8
9
# File 'lib/feedzirra/reader.rb', line 7

def urls
  @urls
end

Instance Method Details

#fetchObject

Map all urls to Feed objects, pulling existing feeds from Backend where available, then slices and fetches feeds in chunks of 30.



16
17
18
19
20
# File 'lib/feedzirra/reader.rb', line 16

def fetch
  multi = multi_from(@urls, @options)
  multi.run
  multi.responses.size == 1 ? multi.responses.values.first : multi.responses.values 
end