Class: RGallery::Pages

Inherits:
PhotoConfig show all
Includes:
Enumerable
Defined in:
lib/rails-gallery/rgallery/pages.rb

Instance Attribute Summary

Attributes inherited from PhotoConfig

#options

Instance Method Summary collapse

Constructor Details

#initialize(photo_list = [], options = {}) ⇒ Pages

Returns a new instance of Pages.



5
6
7
8
# File 'lib/rails-gallery/rgallery/pages.rb', line 5

def initialize photo_list = [], options = {}
  super options
  self.send(:<<, photo_list) unless photo_list.blank?
end

Instance Method Details

#<<(photo_list) ⇒ Object



22
23
24
# File 'lib/rails-gallery/rgallery/pages.rb', line 22

def << photo_list
  pages << RGallery::Page.new(photo_list, options)
end

#add_photo_sources(sources_hash) ⇒ Object

a Hash where each element is a source of the form: ‘banner’ => [‘banner-HD’, sizing: ‘2x’, ‘banner-phone’, sizing: ‘100w’]



34
35
36
37
38
# File 'lib/rails-gallery/rgallery/pages.rb', line 34

def add_photo_sources sources_hash
  sources_hash.each do |source|
    pages.add_photo_w_sources source
  end
end

#add_photo_w_sources(source) ⇒ Object

a source is a hash of the form: ‘banner’ => [‘banner-HD’, sizing: ‘2x’, ‘banner-phone’, sizing: ‘100w’]



28
29
30
# File 'lib/rails-gallery/rgallery/pages.rb', line 28

def add_photo_w_sources source
  pages << RGallery::Page.from_source(source, options)
end

#each(&block) ⇒ Object



10
11
12
# File 'lib/rails-gallery/rgallery/pages.rb', line 10

def each &block
  pages.each {|page| yield page }
end

#firstObject



18
19
20
# File 'lib/rails-gallery/rgallery/pages.rb', line 18

def first
  pages.first || []
end

#remainderObject



14
15
16
# File 'lib/rails-gallery/rgallery/pages.rb', line 14

def remainder
  pages[1..-1] || []
end