Sha256: ebdd337fed02dc157583bec6ef6711f3e8aa18544794f4b54bf9aa910e214ac2
Contents?: true
Size: 746 Bytes
Versions: 11
Compression:
Stored size: 746 Bytes
Contents
module BitWallet class Accounts < Array attr_reader :wallet delegate :client, to: :wallet def with_balance self.select { |account| account.balance > 0 } end def initialize(wallet) @wallet = wallet existing_accounts.each do |name| self.new(name) end end def new(name) if self.includes_account_name?(name) account = self.find {|a| a.name == name} else account = BitWallet::Account.new(wallet, name) self << account end account end def includes_account_name?(account_name) self.find {|a| a.name == account_name}.present? end private def existing_accounts client.listaccounts.keys end end end
Version data entries
11 entries across 11 versions & 1 rubygems