Class: Image
- Inherits:
-
Document
- Object
- ActiveRecord::Base
- MLS::Model
- Document
- Image
- Defined in:
- lib/mls/document.rb
Instance Method Summary collapse
Methods inherited from Document
#aspect_ratio, create, find_matching, #height, #path, #width
Instance Method Details
#url(options = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/mls/document.rb', line 63 def 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]}/#{hash_key}.#{[:format]}" result += "?#{url_params.to_param}" if url_params.size > 0 result end |