Module: Url2png
- Extended by:
- Url2png
- Included in:
- Url2png
- Defined in:
- lib/url2png/config.rb,
lib/url2png/dimensions.rb,
lib/url2png/helpers/common.rb
Defined Under Namespace
Modules: Dimensions, Helpers
Constant Summary
collapse
- MODES =
%w{production placehold dummy}
Instance Method Summary
collapse
Instance Method Details
#api_key ⇒ Object
21
22
23
24
|
# File 'lib/url2png/config.rb', line 21
def api_key
raise 'Url2png error: No public key defined!' if @api_key.nil?
@api_key
end
|
#api_key=(api_key) ⇒ Object
17
18
19
|
# File 'lib/url2png/config.rb', line 17
def api_key=api_key
@api_key=api_key
end
|
#api_version ⇒ Object
48
49
50
|
# File 'lib/url2png/config.rb', line 48
def api_version
@api_version || 'v6' end
|
#api_version=(api_version) ⇒ Object
44
45
46
|
# File 'lib/url2png/config.rb', line 44
def api_version=api_version
@api_version = api_version || 'v6' end
|
#config(c = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/url2png/config.rb', line 7
def config c = {}
self.api_key = c[:api_key]
self.private_key = c[:private_key]
self.mode = c[:mode] if c[:mode]
self.api_version = c[:api_version] if c[:api_version]
end
|
#default_size ⇒ Object
56
57
58
|
# File 'lib/url2png/config.rb', line 56
def default_size
@default_size || "400x400"
end
|
#default_size=(default_size) ⇒ Object
52
53
54
|
# File 'lib/url2png/config.rb', line 52
def default_size=default_size
@default_size = default_size || "400x400"
end
|
#mode ⇒ Object
40
41
42
|
# File 'lib/url2png/config.rb', line 40
def mode
@mode ||= 'production' end
|
#mode=(mode) ⇒ Object
35
36
37
38
|
# File 'lib/url2png/config.rb', line 35
def mode=mode
raise "Url2png error: Invalid mode, only #{ MODES.join(', ') } are allowed" unless MODES.include?(mode.to_s)
@mode = mode.to_s
end
|
#private_key ⇒ Object
30
31
32
33
|
# File 'lib/url2png/config.rb', line 30
def private_key
raise 'Url2png error: No private key defined!' if @private_key.nil?
@private_key
end
|
#private_key=(private_key) ⇒ Object
26
27
28
|
# File 'lib/url2png/config.rb', line 26
def private_key=private_key
@private_key = private_key
end
|
#token(param) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/url2png/config.rb', line 60
def token param
case self.api_version
when 'v6'
Digest::MD5.hexdigest("#{param}#{self.private_key}")
when 'v4', 'v3'
Digest::MD5.hexdigest("#{self.private_key}+#{param}")
end
end
|