Sha256: 34bc4be13ae5a33112abd1e9d5d6de26b75b4fb986b20078cda3f0974fa0aed4

Contents?: true

Size: 922 Bytes

Versions: 4

Compression:

Stored size: 922 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,
      :name,
      :pass,
    ]

    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.name       = nil
      self.pass       = nil
      self
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mtgox-0.5.1 lib/mtgox/configuration.rb
mtgox-0.5.0 lib/mtgox/configuration.rb
mtgox-0.4.1 lib/mtgox/configuration.rb
mtgox-0.4.0 lib/mtgox/configuration.rb