Class: Thumbor::Cascade

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/thumbor/cascade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = false, image = nil) ⇒ Cascade

Returns a new instance of Cascade.



32
33
34
35
36
37
38
# File 'lib/thumbor/cascade.rb', line 32

def initialize(key=false, image=nil)
  @key = key
  @image = image
  @options = {}
  @filters = []
  @old_crypto = Thumbor::CryptoURL.new @key
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/thumbor/cascade.rb', line 48

def method_missing(m, *args)
  if /^(.+)_filter$/.match(m.to_s)
    @filters << "#{$1}(#{escape_args(args).join(',')})"
    self
  else
    super
  end
end

Instance Attribute Details

#filtersObject

Returns the value of attribute filters.



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

def filters
  @filters
end

#imageObject

Returns the value of attribute image.



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

def image
  @image
end

#old_cryptoObject

Returns the value of attribute old_crypto.



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

def old_crypto
  @old_crypto
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#generateObject



44
45
46
# File 'lib/thumbor/cascade.rb', line 44

def generate
  @old_crypto.generate prepare_options(@options).merge({image: @image, filters: @filters})
end

#url_forObject



40
41
42
# File 'lib/thumbor/cascade.rb', line 40

def url_for
  @old_crypto.url_for prepare_options(@options).merge({image: @image, filters: @filters})
end