Module: ScreenshotMachine::Configuration

Included in:
ScreenshotMachine
Defined in:
lib/screenshot_machine/configuration.rb

Constant Summary collapse

VALID_PARAMS_KEYS =

An array of valid keys in the options hash when configuring TweetStream.

[
:size,
:format,
:cacheLimit,
:timeout,
:url,
:key].freeze
DEFAULT_SIZE =

T, S, E, N, M, L, X, F

"L"
DEFAULT_FORMAT =

JPG, GIF, PNG

"JPG"
DEFAULT_CACHELIMIT =

0-14 in days

14
DEFAULT_TIMEOUT =

0, 200, 400, 600, 800, 1000 in ms

200
DEFAULT_URL =
nil
DEFAULT_KEY =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



23
24
25
# File 'lib/screenshot_machine/configuration.rb', line 23

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



28
29
30
# File 'lib/screenshot_machine/configuration.rb', line 28

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



33
34
35
# File 'lib/screenshot_machine/configuration.rb', line 33

def options
  Hash[*VALID_PARAMS_KEYS.map {|key| [key, send(key)] }.flatten]
end

#resetObject

Reset all configuration options to defaults



38
39
40
41
42
43
44
45
46
# File 'lib/screenshot_machine/configuration.rb', line 38

def reset
  self.size       = DEFAULT_SIZE
  self.format     = DEFAULT_FORMAT
  self.cacheLimit = DEFAULT_CACHELIMIT      
  self.timeout    = DEFAULT_TIMEOUT     
  self.url        = DEFAULT_URL
  self.key        = DEFAULT_KEY
  self
end