Class: Bresson::ImageReference

Inherits:
Object
  • Object
show all
Defined in:
lib/bresson/image_reference.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ImageReference

Returns a new instance of ImageReference.



5
6
7
8
9
# File 'lib/bresson/image_reference.rb', line 5

def initialize args
  @item = eval "Bresson::#{args[:source]}.new"
  @link = args[:link]
  @legend = args[:legend]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



11
12
13
# File 'lib/bresson/image_reference.rb', line 11

def method_missing name, *args
  eval "@item.#{name}(args)"
end

Instance Attribute Details

#itemObject

Returns the value of attribute item.



3
4
5
# File 'lib/bresson/image_reference.rb', line 3

def item
  @item
end

#legendObject

Returns the value of attribute legend.



3
4
5
# File 'lib/bresson/image_reference.rb', line 3

def legend
  @legend
end

Returns the value of attribute link.



3
4
5
# File 'lib/bresson/image_reference.rb', line 3

def link
  @link
end

Instance Method Details

#thumbObject



15
16
17
# File 'lib/bresson/image_reference.rb', line 15

def thumb
  @link.split(".com/").join(".com/thumb/")
end

#to_sObject



19
20
21
# File 'lib/bresson/image_reference.rb', line 19

def to_s
  '{"reference":"upload","source":"'+@item.class.to_s.split('::').last+'","link":"'+@link+'"}'
end