Class: Imagga::BaseOptions

Inherits:
Object
  • Object
show all
Includes:
Parametizer
Defined in:
lib/imagga/options.rb

Direct Known Subclasses

CropOptions, ExtractOptions, RankOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parametizer

#build_boolean_options, #build_comma_separated_string

Constructor Details

#initialize(api_key, api_secret) ⇒ BaseOptions

Returns a new instance of BaseOptions.



6
7
8
9
10
# File 'lib/imagga/options.rb', line 6

def initialize(api_key, api_secret)
  @version    = '1.0'
  @api_key    = api_key    || raise_missing(:api_key)
  @api_secret = api_secret || raise_missing(:api_secret)
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/imagga/options.rb', line 4

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



4
5
6
# File 'lib/imagga/options.rb', line 4

def api_secret
  @api_secret
end

#versionObject

Returns the value of attribute version.



4
5
6
# File 'lib/imagga/options.rb', line 4

def version
  @version
end

Instance Method Details

#base_optionsObject



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

def base_options
  { v: version, api_key: api_key }
end

#options(opts = {}) ⇒ Object



23
24
25
# File 'lib/imagga/options.rb', line 23

def options(opts={})
  {}
end

#sign(options) ⇒ Object



16
17
18
19
20
21
# File 'lib/imagga/options.rb', line 16

def sign(options)
  sorted_options_string = options.keys.sort.map do |key|
    "%s=%s" % [key.to_s, options[key]]
  end.join('') << api_secret
  Digest::MD5.hexdigest(sorted_options_string)
end