Class: Photo

Inherits:
MLS::Model show all
Defined in:
lib/mls/photo.rb

Instance Method Summary collapse

Instance Method Details

#url(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mls/photo.rb', line 5

def url(options={})
  options.reverse_merge!({
    :style => nil,
    :protocol => "http",
    :bg => nil,
    :format => "jpg"
  });
  url_params = {s: options[:style], bg: options[:bg]}.select{ |k, v| v }
  result = "#{options[:protocol]}://#{MLS.image_host}/#{digest}.#{options[:format]}"
  result += "?#{url_params.to_param}" if url_params.size > 0

  result
end