Sha256: 3aaa50c575f311124ed11775a7758ef4d1e959579d2a0ac1002a1332444a2f19

Contents?: true

Size: 519 Bytes

Versions: 42

Compression:

Stored size: 519 Bytes

Contents

module ShopifyAPI
  class Image < Base
    init_prefix :product
    
    # generate a method for each possible image variant
    [:pico, :icon, :thumb, :small, :compact, :medium, :large, :grande, :original].each do |m|
      reg_exp_match = "/\\1_#{m}.\\2"
      define_method(m) { src.gsub(/\/(.*)\.(\w{2,4})/, reg_exp_match) }
    end
    
    def attach_image(data, filename = nil)
      attributes['attachment'] = Base64.encode64(data)
      attributes['filename'] = filename unless filename.nil?
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
shopify_api-4.10.0 lib/shopify_api/resources/image.rb
shopify_api-4.9.1 lib/shopify_api/resources/image.rb
shopify_api-4.9.0 lib/shopify_api/resources/image.rb
shopify_api-4.8.0 lib/shopify_api/resources/image.rb
shopify_api-4.7.1 lib/shopify_api/resources/image.rb
shopify_api-4.7.0 lib/shopify_api/resources/image.rb
shopify_api-4.6.0 lib/shopify_api/resources/image.rb
shopify_api-4.5.0 lib/shopify_api/resources/image.rb
shopify_api-4.4.0 lib/shopify_api/resources/image.rb
shopify_api-4.3.9 lib/shopify_api/resources/image.rb
shopify_api-4.3.8 lib/shopify_api/resources/image.rb
shopify_api-4.3.7 lib/shopify_api/resources/image.rb
shopify_api-4.3.6 lib/shopify_api/resources/image.rb
shopify_api-4.3.5 lib/shopify_api/resources/image.rb
shopify_api-4.3.4 lib/shopify_api/resources/image.rb
shopify_api-4.3.3 lib/shopify_api/resources/image.rb
shopify_api-4.3.2 lib/shopify_api/resources/image.rb
shopify_api-4.3.1 lib/shopify_api/resources/image.rb
shopify_api-4.3.0 lib/shopify_api/resources/image.rb
shopify_api-4.2.2 lib/shopify_api/resources/image.rb