Class: Usmu::Collections::Collection
- Inherits:
-
Object
- Object
- Usmu::Collections::Collection
- Defined in:
- lib/usmu/collections.rb
Instance Method Summary collapse
- #each(&block) ⇒ void
-
#initialize(pages) ⇒ Collection
constructor
A new instance of Collection.
- #next_from(file) ⇒ void
- #pages ⇒ void
- #previous_from(file) ⇒ void
Constructor Details
#initialize(pages) ⇒ Collection
Returns a new instance of Collection.
25 26 27 |
# File 'lib/usmu/collections.rb', line 25 def initialize(pages) @pages = pages end |
Instance Method Details
#each(&block) ⇒ void
33 34 35 |
# File 'lib/usmu/collections.rb', line 33 def each(&block) pages.each &block end |
#next_from(file) ⇒ void
43 44 45 46 47 |
# File 'lib/usmu/collections.rb', line 43 def next_from(file) i = @pages.index file return unless i @pages[(i + 1) % @pages.length] end |
#pages ⇒ void
29 30 31 |
# File 'lib/usmu/collections.rb', line 29 def pages @pages.dup end |
#previous_from(file) ⇒ void
37 38 39 40 41 |
# File 'lib/usmu/collections.rb', line 37 def previous_from(file) i = @pages.index file return unless i @pages[(i - 1) % @pages.length] end |