Class: Bcoin::Client::Collection
- Inherits:
-
Object
- Object
- Bcoin::Client::Collection
- Includes:
- HttpMethods, Enumerable
- Defined in:
- lib/bcoin/client/collection.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#error ⇒ Object
Returns the value of attribute error.
Instance Method Summary collapse
-
#base_path ⇒ Object
Redefine in sub class.
- #each(&block) ⇒ Object
- #error? ⇒ Boolean
-
#initialize(client, collection = []) ⇒ Collection
constructor
A new instance of Collection.
- #inspect ⇒ Object
-
#refresh!(path = '') ⇒ Object
Allow for overriding of the path for situations like the wallet list retrieval.
Methods included from HttpMethods
#delete, #get, #post, #put, #wallet_token
Constructor Details
#initialize(client, collection = []) ⇒ Collection
Returns a new instance of Collection.
12 13 14 15 |
# File 'lib/bcoin/client/collection.rb', line 12 def initialize client, collection = [] @client = client @collection = collection end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/bcoin/client/collection.rb', line 10 def client @client end |
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
10 11 12 |
# File 'lib/bcoin/client/collection.rb', line 10 def collection @collection end |
#error ⇒ Object
Returns the value of attribute error.
10 11 12 |
# File 'lib/bcoin/client/collection.rb', line 10 def error @error end |
Instance Method Details
#base_path ⇒ Object
Redefine in sub class
22 23 24 |
# File 'lib/bcoin/client/collection.rb', line 22 def base_path '/collection' end |
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/bcoin/client/collection.rb', line 26 def each &block @collection.each {|w| block.call(w) } end |
#error? ⇒ Boolean
37 38 39 |
# File 'lib/bcoin/client/collection.rb', line 37 def error? @error ? true : false end |
#inspect ⇒ Object
17 18 19 |
# File 'lib/bcoin/client/collection.rb', line 17 def inspect printf "#<%s @collection=%p>", self.class.name, @collection end |
#refresh!(path = '') ⇒ Object
Allow for overriding of the path for situations like the wallet list retrieval. See the comment for Wallets#base_path for details.
33 34 35 |
# File 'lib/bcoin/client/collection.rb', line 33 def refresh! path = '' get path + '/' end |