Class: Btc::Client
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ Client
constructor
A new instance of Client.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 |
# File 'lib/btc/client.rb', line 6 def initialize(settings={}) # covert hash key to symbol # http://stackoverflow.com/questions/800122/best-way-to-convert-strings-to-symbols-in-hash @settings = Btc::Settings && Btc::Settings.btc.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} @settings ||= {} @settings.merge! settings end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/btc/client.rb', line 14 def method_missing(method, *args) method = method.to_s.gsub(/\_/, "") Btc::Rpc.query( method, args, :url => @settings[:url], :username => @settings[:username], :password => @settings[:password]) end |