Sha256: be80f76452dbfdf0dff375efbdee59b871ef911e9b8e99230fbb2465a5980608

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 Bytes

Contents

require 'mtgox/version'

module MtGox
  module Configuration
    # An array of valid keys in the options hash when configuring a {MtGox::Client}
    VALID_OPTIONS_KEYS = [
      :commission,
      :password,
      :username,
    ]

    DEFAULT_COMMISSION = 0.0065.freeze

    attr_accessor *VALID_OPTIONS_KEYS

    # When this module is extended, set all configuration options to their default values
    def self.extended(base)
      base.reset
    end

    # Convenience method to allow configuration options to be set in a block
    def configure
      yield self
    end

    # Create a hash of options and their values
    def options
      options = {}
      VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
      options
    end

    # Reset all configuration options to defaults
    def reset
      self.commission = DEFAULT_COMMISSION
      self.password   = nil
      self.username   = nil
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mtgox-0.7.1 lib/mtgox/configuration.rb
mtgox-0.7.0 lib/mtgox/configuration.rb
mtgox-0.6.0 lib/mtgox/configuration.rb