Sha256: 0f762837b81186ab019a90884ef70c5df4efd0b2cdca830c9d350c04c86d6b77

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 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
      #   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

1 entries across 1 versions & 1 rubygems

Version Path
gecko-ruby-0.0.4 lib/gecko/record/image.rb