Sha256: 9f27cd83d1fc2f960b79c49f2fe15e23803493f25e80b8fdf6b9dc5b5872afbf

Contents?: true

Size: 942 Bytes

Versions: 3

Compression:

Stored size: 942 Bytes

Contents

require 'gecko/record/base'

module Gecko
  module Record
    class Image < Base
      AVAILABLE_SIZES = [:full, :thumbnail]

      belongs_to :variant
      belongs_to :uploader, class_name: "User"
      attribute :name,             String
      attribute :position,         Integer
      attribute :base_path,        String
      attribute :file_name,        String
      attribute :versions,         Array[String]
      # attribute :image_processing, Boolean

      # URL for image
      #
      # @param [Symbol] :size (:full) The image size, currently only :full,
      #  :medium and :thumbnail supported
      #
      # @return [String]
      #
      # @api public
      def url(size = :full)
        if size == :full
          file_path = file_name
        else
          file_path = "#{size}_#{file_name}"
        end
        [base_path, file_path].join("/")
      end
    end

    class ImageAdapter < BaseAdapter
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gecko-ruby-0.0.7 lib/gecko/record/image.rb
gecko-ruby-0.0.6 lib/gecko/record/image.rb
gecko-ruby-0.0.5 lib/gecko/record/image.rb