Class: Bitcoin::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin/account.rb

Overview

Author:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Account) initialize(account_label = '', balance = nil)

A new instance of Account



11
12
13
14
# File 'lib/bitcoin/account.rb', line 11

def initialize( = '', balance = nil)
	@identifier = 
    @balance = balance
end

Instance Attribute Details

- (Object) identifier (readonly)

The account identifier or label.



9
10
11
# File 'lib/bitcoin/account.rb', line 9

def identifier
  @identifier
end

Instance Method Details

- (Object) ==(other)

Compare two accounts.

Two accounts are deemed the same if their labels match.



42
43
44
# File 'lib/bitcoin/account.rb', line 42

def ==(other)
  to_s == other.to_s
end

- (Float) balance

Return the current balance of this account.

Note that this balance would have been generated with a specified number of minimum confirmations which means it may include or exclude unconfirmed transactions. If however no balance has been retrieved it will retrieve one with a default minimum confimration count of 1.

Returns:

  • (Float)

    The balance on the account.



24
25
26
# File 'lib/bitcoin/account.rb', line 24

def balance
  @balance ||= Bitcoin::Client.get_balance(@identifier)
end

- (String) to_s

String representation of an Account.

Examples:

"Your Account is called: '#{}'"
# => "Your Account is called: 'Savings'"

Returns:

  • (String)

    Label identifying the Account.



35
36
37
# File 'lib/bitcoin/account.rb', line 35

def to_s
	identifier
end