Class: Alchemy::Picture::Url

Inherits:
Object
  • Object
show all
Defined in:
app/models/alchemy/picture/url.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variant) ⇒ Url

Returns a new instance of Url.

Parameters:

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'app/models/alchemy/picture/url.rb', line 10

def initialize(variant)
  raise ArgumentError, "Variant missing!" if variant.nil?

  @variant = variant
end

Instance Attribute Details

#thumbObject (readonly)

Returns the value of attribute thumb.



6
7
8
# File 'app/models/alchemy/picture/url.rb', line 6

def thumb
  @thumb
end

#variantObject (readonly)

Returns the value of attribute variant.



6
7
8
# File 'app/models/alchemy/picture/url.rb', line 6

def variant
  @variant
end

Instance Method Details

#call(params = {}) ⇒ String

The URL to a variant of a picture

Returns:

  • (String)


20
21
22
23
24
# File 'app/models/alchemy/picture/url.rb', line 20

def call(params = {})
  return variant.image.url(params) unless processible_image?

  "/#{uid}"
end