Module: MtGox::Configuration

Included in:
MtGox
Defined in:
lib/mtgox/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring a MtGox::Client

[
  :commission,
  :key,
  :secret,
]
DEFAULT_COMMISSION =
0.0065.freeze

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



17
18
19
# File 'lib/mtgox/configuration.rb', line 17

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:



22
23
24
# File 'lib/mtgox/configuration.rb', line 22

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



27
28
29
30
31
# File 'lib/mtgox/configuration.rb', line 27

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
  options
end

#resetObject

Reset all configuration options to defaults



34
35
36
37
38
39
# File 'lib/mtgox/configuration.rb', line 34

def reset
  self.commission = DEFAULT_COMMISSION
  self.key   = nil
  self.secret   = nil
  self
end