Class: Bcoin::Client::Base
- Inherits:
-
Object
- Object
- Bcoin::Client::Base
- Includes:
- HttpMethods
- Defined in:
- lib/bcoin/client/base.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#base_path ⇒ Object
Override this in sub class.
- #error=(_error) ⇒ Object
-
#id ⇒ Object
Override this in sub class.
-
#initialize(client, attr = {}) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #refresh! ⇒ Object
- #token=(_token) ⇒ Object
- #wallet_token ⇒ Object
Methods included from HttpMethods
Constructor Details
#initialize(client, attr = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 |
# File 'lib/bcoin/client/base.rb', line 9 def initialize client, attr = {} @client = client self.attributes = attr end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
59 60 61 62 63 64 65 |
# File 'lib/bcoin/client/base.rb', line 59 def method_missing method, *args if @attributes[method].nil? raise NoMethodError else @attributes[method] end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/bcoin/client/base.rb', line 7 def attributes @attributes end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/bcoin/client/base.rb', line 7 def client @client end |
Instance Method Details
#base_path ⇒ Object
Override this in sub class
24 25 26 |
# File 'lib/bcoin/client/base.rb', line 24 def base_path '/base' end |
#error=(_error) ⇒ Object
45 46 47 |
# File 'lib/bcoin/client/base.rb', line 45 def error= _error @attributes[:error] = _error end |
#id ⇒ Object
Override this in sub class
19 20 21 |
# File 'lib/bcoin/client/base.rb', line 19 def id 'base' end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/bcoin/client/base.rb', line 14 def inspect printf "#<%s @attributes=%p>", self.class.name, @attributes end |
#refresh! ⇒ Object
28 29 30 31 |
# File 'lib/bcoin/client/base.rb', line 28 def refresh! self.attributes = get '/' self end |
#token=(_token) ⇒ Object
37 38 39 |
# File 'lib/bcoin/client/base.rb', line 37 def token= _token @attributes[:token] = _token end |
#wallet_token ⇒ Object
33 34 35 |
# File 'lib/bcoin/client/base.rb', line 33 def wallet_token @attributes[:token] if @attributes end |