Class: Tumblargh::Resource::Photo

Inherits:
Base
  • Object
show all
Defined in:
lib/tumblargh/resource/photo.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #context

Instance Method Summary collapse

Methods inherited from Base

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Tumblargh::Resource::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tumblargh::Resource::Base

Instance Method Details

#photo_url(size = 500) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/tumblargh/resource/photo.rb', line 6

def photo_url(size=500)
  size = size.to_i

  res = alt_sizes.select do |p|
    p[:width] == size
  end

  res.empty? ? original_size[:url] : res.first[:url]
end