Class: Bcoin::Client::Collection

Inherits:
Object
  • Object
show all
Includes:
HttpMethods, Enumerable
Defined in:
lib/bcoin/client/collection.rb

Direct Known Subclasses

Accounts, Wallets

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/bcoin/client/collection.rb', line 10

def client
  @client
end

#collectionObject (readonly)

Returns the value of attribute collection.



10
11
12
# File 'lib/bcoin/client/collection.rb', line 10

def collection
  @collection
end

#errorObject

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_pathObject

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

Returns:

  • (Boolean)


37
38
39
# File 'lib/bcoin/client/collection.rb', line 37

def error?
  @error ? true : false
end

#inspectObject



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