Class: Region

Inherits:
MLS::Model show all
Includes:
MLS::Slugger
Defined in:
lib/mls/region.rb

Instance Method Summary collapse

Instance Method Details

#cover_photo_url(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mls/region.rb', line 26

def cover_photo_url(options={})

  options.reverse_merge!({
    :style => nil,
    :bg => nil,
    :protocol => 'https',
    :format => "jpg",
    :host => MLS.image_host
  });

  url_params = { s: options[:style], bg: options[:bg] }.select{ |k, v| v }

  if options[:protocol] == :relative # Protocol Relative
    result = '//'
  else options[:protocol]
    result = "#{options[:protocol]}://"
  end

  result += "#{options[:host]}/#{cover_photo_digest}.#{options[:format]}"
  result += "?#{url_params.to_param}" if url_params.size > 0

  result
end

#nameObject



18
19
20
21
22
23
24
# File 'lib/mls/region.rb', line 18

def name
  if common_name.try(:[], 'eng')
    common_name['eng'].is_a?(Array) ? common_name['eng'].first : common_name['eng']
  else
    official_name['eng'].is_a?(Array) ? official_name['eng'].first : official_name['eng']
  end
end