class RGallery::Page
Public Class Methods
from_source(sources)
click to toggle source
a source is a hash of the form: ‘banner’ => [{src: ‘banner-HD’, sizing: ‘2x’}, {src: ‘banner-phone’, sizing: ‘100w’}] see: add_photo_sources
# File lib/rails-gallery/rgallery/page.rb, line 13 def self.from_source sources page = self.create sources.keys, options @photos ||= sources.map do |key, srclist| photo_class.new key, options.merge(:sources => srclist) end end
new(photo_objs = [], options = {})
click to toggle source
Calls superclass method
# File lib/rails-gallery/rgallery/page.rb, line 5 def initialize photo_objs = [], options = {} @photo_objs = photo_objs super options end
Public Instance Methods
<<(photo_objs)
click to toggle source
# File lib/rails-gallery/rgallery/page.rb, line 21 def << photo_objs @photo_objs ||= [] @photo_objs += [photo_objs].flatten end
add_photo_sources(sources_hash)
click to toggle source
# File lib/rails-gallery/rgallery/page.rb, line 26 def add_photo_sources sources_hash sources_hash.each do |source| add_photo_w_sources source end end
add_photo_w_sources(source)
click to toggle source
# File lib/rails-gallery/rgallery/page.rb, line 32 def add_photo_w_sources source raise ArgumentError, "Must be a hash, was: #{source}" unless source.kind_of? Hash key = source.keys.first srclist = source.values.first raise ArgumentError, "Hash value must be an Array, was: #{srclist}" unless srclist.kind_of? Array self.send :<<, key @photos ||= [] @photos << photo_class.new(key, options.merge(:sources => srclist)) end
each() { |photo| ... }
click to toggle source
# File lib/rails-gallery/rgallery/page.rb, line 53 def each &block photos.each {|photo| yield photo } end
photo_objs()
click to toggle source
# File lib/rails-gallery/rgallery/page.rb, line 43 def photo_objs @photo_objs ||= [] end
photos()
click to toggle source
# File lib/rails-gallery/rgallery/page.rb, line 47 def photos @photos ||= photo_objs.map {|obj| photo_class.new obj, options } end