Class: Imagery

Inherits:
Object
  • Object
show all
Includes:
Core
Defined in:
lib/imagery.rb,
lib/imagery/s3.rb

Defined Under Namespace

Modules: Core, GM, S3

Constant Summary collapse

InvalidImage =

Raised during Imagery#save if the image can’t be recognized.

Class.new(StandardError)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Core

#delete, #initialize, #save, #url

Instance Attribute Details

#idObject (readonly)

A unique id for the image.



12
13
14
# File 'lib/imagery.rb', line 12

def id
  @id
end

#prefixObject (readonly)

Acts as a namespace, e.g. ‘photos`.



9
10
11
# File 'lib/imagery.rb', line 9

def prefix
  @prefix
end

#sizesObject (readonly)

A hash of name => tuple pairs. The name describes the size, e.g. ‘small`.

  • The first element if the tuple is the resize geometry.

  • The second (optional) element describes the extent.



25
26
27
# File 'lib/imagery.rb', line 25

def sizes
  @sizes
end

Class Method Details

.inherited(child) ⇒ Object



123
124
125
# File 'lib/imagery.rb', line 123

def self.inherited(child)
  child.root = root
end

.root(*args) ⇒ Object



114
115
116
# File 'lib/imagery.rb', line 114

def self.root(*args)
  File.join(@root, *args)
end

.root=(path) ⇒ Object



118
119
120
# File 'lib/imagery.rb', line 118

def self.root=(path)
  @root = path
end

Instance Method Details

#ext(file) ⇒ Object

Returns the base filename together with the extension, which defaults to jpg.



106
107
108
# File 'lib/imagery.rb', line 106

def ext(file)
  "#{file}.#{@ext}"
end

#root(*args) ⇒ Object



110
111
112
# File 'lib/imagery.rb', line 110

def root(*args)
  self.class.root(prefix, id, *args)
end