Class: Gecko::Record::Image

Inherits:
Base
  • Object
show all
Defined in:
lib/gecko/record/image.rb

Constant Summary collapse

AVAILABLE_SIZES =
[:full, :thumbnail]

Instance Method Summary collapse

Methods inherited from Base

demodulized_name, #initialize, #persisted?, #save

Methods included from Helpers::AssociationHelper

#belongs_to, #has_many

Methods included from Helpers::ValidationHelper

#errors, #valid?

Methods included from Helpers::SerializationHelper

#_serialize, #as_json, #root, #serializable_hash, #serialize_attribute

Methods included from Helpers::InspectionHelper

#inspect

Constructor Details

This class inherits a constructor from Gecko::Record::Base

Instance Method Details

#url(size = :full) ⇒ String

URL for image

Parameters:

  • :size (Symbol)

    (:full) The image size, currently only :full, :medium and :thumbnail supported

Returns:

  • (String)


25
26
27
28
29
30
31
32
# File 'lib/gecko/record/image.rb', line 25

def url(size = :full)
  if size == :full
    file_path = file_name
  else
    file_path = "#{size}_#{file_name}"
  end
  [base_path, file_path].join("/")
end