Class: Giddy::Lightbox

Inherits:
Object
  • Object
show all
Defined in:
lib/giddy/lightbox.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs, mediator) ⇒ Lightbox

Returns a new instance of Lightbox.



3
4
5
6
# File 'lib/giddy/lightbox.rb', line 3

def initialize(attrs, mediator)
  @attrs = Utils.rubified_hash(attrs)
  @mediator = mediator
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



13
14
15
# File 'lib/giddy/lightbox.rb', line 13

def method_missing(method, *args, &block)
  @attrs.fetch(method, nil)
end

Instance Method Details

#imagesObject



8
9
10
11
# File 'lib/giddy/lightbox.rb', line 8

def images
  image_ids = lightbox_items.map { |img| img[:asset_id] }
  Search.new(@mediator).get_image_details(image_ids)
end

#to_sObject



17
18
19
20
# File 'lib/giddy/lightbox.rb', line 17

def to_s
  as = @attrs.map { |k,v| "#{k}=#{v}" }.join(", ")
  "<Lightbox #{as}>" 
end