Sha256: 432e583e6cad950aa68903ed359a41fc3569331391f5316dfbb994e83fd5f795

Contents?: true

Size: 543 Bytes

Versions: 13

Compression:

Stored size: 543 Bytes

Contents

module ShopifyAPI
  class Image < Base
    self.prefix = "/admin/products/:product_id/"
    
    # 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

13 entries across 13 versions & 2 rubygems

Version Path
shopify_api-3.1.6 lib/shopify_api/resources/image.rb
shopify_api-3.1.5 lib/shopify_api/resources/image.rb
shopify_api-3.1.3 lib/shopify_api/resources/image.rb
shopify_api-3.1.2 lib/shopify_api/resources/image.rb
shopify_api-3.0.3 lib/shopify_api/resources/image.rb
shopify_api-3.0.2 lib/shopify_api/resources/image.rb
shopify_api-3.0.1 lib/shopify_api/resources/image.rb
shopify_api-3.0.0 lib/shopify_api/resources/image.rb
shopify_api-2.3.0 lib/shopify_api/resources/image.rb
shopify_api-2.2.0 lib/shopify_api/resources/image.rb
shopify_api-2.1.0 lib/shopify_api/resources/image.rb
shopify_api-2.0.0 lib/shopify_api/resources/image.rb
th_shopify_api-1.2.6.pre lib/shopify_api/resources/image.rb