Class: WaffleAPI::Client
- Inherits:
-
Object
- Object
- WaffleAPI::Client
- Includes:
- AddressValidator, Helpers
- Defined in:
- lib/waffle_api/client.rb
Overview
Constant Summary
Constants included from Helpers
Helpers::INVALIDATION_TIME, Helpers::NOT_FOUND_ERROR
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
Instance Method Summary collapse
- #balances ⇒ Object
- #hashrate ⇒ Object
-
#initialize(address: nil) ⇒ Client
constructor
A new instance of Client.
-
#method_missing(method, *args, &block) ⇒ Object
This is for not yet suported keys.
- #payments ⇒ Object
- #workers ⇒ Object
Methods included from Helpers
#call_uri, #data_recent!, #data_recent?, #request_json, #stats
Constructor Details
#initialize(address: nil) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 |
# File 'lib/waffle_api/client.rb', line 22 def initialize(address: nil) @address = address || ENV['BTC_ADDRESS'] fail Error::EmptyAddress if @address.nil? || @address.empty? fail Error::BadAddress, @address unless valid_address? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
This is for not yet suported keys
65 66 67 68 69 |
# File 'lib/waffle_api/client.rb', line 65 def method_missing(method, *args, &block) stats method.to_s rescue Error::UnknownKey super method, *args, &block end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
20 21 22 |
# File 'lib/waffle_api/client.rb', line 20 def address @address end |
Instance Method Details
#balances ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/waffle_api/client.rb', line 44 def balances balances = stats 'balances' WaffleAPI::Balances.new( sent: balances['sent'], confirmed: balances['confirmed'], unconverted: balances['unconverted'] ) end |
#hashrate ⇒ Object
29 30 31 |
# File 'lib/waffle_api/client.rb', line 29 def hashrate stats 'hash_rate' end |