Class: Pixiv::PageCollection::Enumerator
- Inherits:
-
Object
- Object
- Pixiv::PageCollection::Enumerator
- Includes:
- Enumerable
- Defined in:
- lib/pixiv/page_collection.rb
Instance Method Summary collapse
- #each_page ⇒ Object (also: #each)
- #each_slice(n = nil) ⇒ Object
-
#initialize(client, collection) ⇒ Enumerator
constructor
A new instance of Enumerator.
Constructor Details
#initialize(client, collection) ⇒ Enumerator
Returns a new instance of Enumerator.
35 36 37 38 |
# File 'lib/pixiv/page_collection.rb', line 35 def initialize(client, collection) @client = client @collection = collection end |
Instance Method Details
#each_page ⇒ Object Also known as: each
40 41 42 43 44 45 46 |
# File 'lib/pixiv/page_collection.rb', line 40 def each_page each_collection do |collection| pages_from_collection(collection).each do |page| yield page end end end |
#each_slice(n = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pixiv/page_collection.rb', line 50 def each_slice(n = nil) if n super else if block_given? each_collection do |collection| yield pages_from_collection(collection) end else ::Enumerator.new {|y| each_slice {|slice| y << slice } } end end end |