Class: Region
- Inherits:
-
MLS::Model
- Object
- ActiveRecord::Base
- MLS::Model
- Region
- Includes:
- MLS::Slugger
- Defined in:
- lib/mls/models/region.rb
Constant Summary collapse
- COUNTRY_TYPES =
["Monarchy", "Republic"]
- STATE_TYPES =
["State", "Territory", "Commonwealth", "Province"]
- CITY_TYPES =
["City", "Municipality", "Village", "Rural Municipality", "Town", "Resort Village", "Community Government"]
Instance Method Summary collapse
Instance Method Details
#cover_photo_url(options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/mls/models/region.rb', line 39 def cover_photo_url(={}) .reverse_merge!({ :style => nil, :bg => nil, :protocol => 'https', :format => "jpg", :host => MLS.image_host }); url_params = { s: [:style], bg: [:bg] }.select{ |k, v| v } if [:protocol] == :relative # Protocol Relative result = '//' else [:protocol] result = "#{[:protocol]}://" end result += "#{[:host]}/#{cover_photo_digest}.#{[:format]}" result += "?#{url_params.to_param}" if url_params.size > 0 result end |
#name ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mls/models/region.rb', line 23 def name if common_name.try(:[], 'eng') common_name['eng'].is_a?(Array) ? common_name['eng'].first : common_name['eng'] elsif official_name.try(:[], 'eng') official_name['eng'].is_a?(Array) ? official_name['eng'].first : official_name['eng'] elsif common_name && common_name.size > 0 common_name.values.first else official_name.values.first end end |
#tree_name ⇒ Object
35 36 37 |
# File 'lib/mls/models/region.rb', line 35 def tree_name slug.split("/").map(&:humanize).map(&:titleize).map{|r| r.length == 2 ? r.upcase : r}.reverse.join(", ") end |