Class: Imgwire::Image
- Inherits:
-
ImgwireGenerated::ImageSchema
- Object
- ImgwireGenerated::ImageSchema
- Imgwire::Image
- Defined in:
- lib/imgwire/image.rb
Constant Summary collapse
- PRESETS =
%w[thumbnail small medium large].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.wrap(value) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/imgwire/image.rb', line 10 def self.wrap(value) return value if value.is_a?(self) if value.is_a?(ImgwireGenerated::ImageSchema) attributes = ImgwireGenerated::ImageSchema.attribute_map.keys.to_h do |attribute| [attribute, value.public_send(attribute)] end return new(attributes) end return build_from_hash(value.to_hash) if value.respond_to?(:to_hash) build_from_hash(value) end |
Instance Method Details
#url(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/imgwire/image.rb', line 24 def url( = {}) = symbolize_keys() path = build_preset_path([:preset]) query = Imgwire::URLTransformations.build_query(.except(:preset)) uri = URI.parse(cdn_url) uri.path = path uri.query = query.empty? ? nil : URI.encode_www_form(query.sort_by(&:first)) uri.to_s end |