Class: Usmu::Collections::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/usmu/collections.rb

Instance Method Summary collapse

Constructor Details

#initialize(pages) ⇒ Collection

Returns a new instance of Collection.

Parameters:



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

#pagesvoid



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