Class: RGallery::Pages
- Inherits:
-
PhotoConfig
- Object
- PhotoConfig
- RGallery::Pages
- Includes:
- Enumerable
- Defined in:
- lib/rails-gallery/rgallery/pages.rb
Instance Attribute Summary
Attributes inherited from PhotoConfig
Instance Method Summary collapse
- #<<(photo_list) ⇒ Object
-
#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’].
-
#add_photo_w_sources(source) ⇒ Object
a source is a hash of the form: ‘banner’ => [‘banner-HD’, sizing: ‘2x’, ‘banner-phone’, sizing: ‘100w’].
- #each(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(photo_list = [], options = {}) ⇒ Pages
constructor
A new instance of Pages.
- #remainder ⇒ Object
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 = [], = {} super 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, ) 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, ) 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 |
#first ⇒ Object
18 19 20 |
# File 'lib/rails-gallery/rgallery/pages.rb', line 18 def first pages.first || [] end |
#remainder ⇒ Object
14 15 16 |
# File 'lib/rails-gallery/rgallery/pages.rb', line 14 def remainder pages[1..-1] || [] end |