class HasFilepickerImage::UrlBuilder::ApiOptions
Constants
- ALL_OPTIONS
- CONVERSION_OPTIONS
- DEFAULT_OPTIONS
- RETRIEVAL_OPTIONS
Public Class Methods
new(styles, hash_or_style = {}, hash = {})
click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 36 def initialize(styles, hash_or_style = {}, hash = {}) @styles = styles options = if hash_or_style.is_a?(Hash) hash_or_style.assert_valid_keys(*ALL_OPTIONS) hash_or_style else hash.assert_valid_keys(*ALL_OPTIONS) style_api_options(hash_or_style).merge(hash) end merge! options merge! defaults.except *options.keys.map(&:to_sym) end
Public Instance Methods
with_conversion_options?()
click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 51 def with_conversion_options? (keys.map(&:to_sym) & CONVERSION_OPTIONS).present? end
Private Instance Methods
defaults()
click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 57 def defaults if with_conversion_options? DEFAULT_OPTIONS else DEFAULT_OPTIONS.slice(*RETRIEVAL_OPTIONS) end end
style_api_options(style)
click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 65 def style_api_options(style) { :w => @styles[style][0], :h => @styles[style][1] } end