Skip to content

Instantly share code, notes, and snippets.

@nmarley
Last active Jan 1, 2016
Embed
What would you like to do?
Ideal implementation of TradeAPI - factors out details of retrieving key/secret
#! /usr/bin/env ruby
class TradeAPI
attr_accessor :key
attr_accessor :secret
def initialize(key, secret)
@key = key
@secret = secret
unless @key && @secret
# throw exception, key and secret must be set
raise ArgumentError, "Both key and secret must be set."
end
end
end
#t1 = TradeAPI.new
t2 = TradeAPI.new('keyisthekey', 'übersecret')
puts "t2 key = #{t2.key}"
puts "t2 secret = #{t2.secret}"
t2.key = 'GrandMasterKey!'
puts "t2 key = #{t2.key}"
puts "t2 secret = #{t2.secret}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment