Class: Imaginable::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/imaginable/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid, token, version) ⇒ Image

Returns a new instance of Image.



7
8
9
10
11
# File 'lib/imaginable/image.rb', line 7

def initialize(uuid, token, version)
  @uuid = uuid
  @token = token
  @version = version
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/imaginable/image.rb', line 5

def token
  @token
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/imaginable/image.rb', line 5

def uuid
  @uuid
end

Instance Method Details

#url(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/imaginable/image.rb', line 13

def url(options = {})
  options[:width] ||= 0
  options[:format] ||= 'original'
  
  height = options.has_key?(:height) ? "-#{options[:height]}" : ""
  
  "#{Imaginable.scale_server}/image/#{@uuid}-#{@version}-#{options[:format]}-#{options[:width]}#{height}.jpg"
end