Class: Bitcoiner::Account
- Inherits:
-
Object
- Object
- Bitcoiner::Account
- Defined in:
- lib/bitcoiner/account.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #address ⇒ Object
- #balance(min_confirmations = 1) ⇒ Object
-
#initialize(client, name) ⇒ Account
constructor
A new instance of Account.
- #inspect ⇒ Object
- #send_to(destination, amount) ⇒ Object
- #transactions ⇒ Object
Constructor Details
#initialize(client, name) ⇒ Account
Returns a new instance of Account.
7 8 9 10 |
# File 'lib/bitcoiner/account.rb', line 7 def initialize(client, name) @client = client @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/bitcoiner/account.rb', line 5 def name @name end |
Instance Method Details
#address ⇒ Object
25 26 27 |
# File 'lib/bitcoiner/account.rb', line 25 def address @address ||= @client.request 'getaccountaddress', @name end |
#balance(min_confirmations = 1) ⇒ Object
21 22 23 |
# File 'lib/bitcoiner/account.rb', line 21 def balance(min_confirmations = 1) @balance ||= @client.request 'getbalance', @name, min_confirmations.to_i end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/bitcoiner/account.rb', line 12 def inspect "#<Bitcoiner::Account #{@name.inspect} >" end |
#send_to(destination, amount) ⇒ Object
16 17 18 19 |
# File 'lib/bitcoiner/account.rb', line 16 def send_to(destination, amount) txn_id = @client.request 'sendfrom', @name, destination, amount Transaction.new @clientm, self, txn_id end |
#transactions ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/bitcoiner/account.rb', line 29 def transactions txn_array = @client.request 'listtransactions', @name txn_array.map do |h| Transaction.new @client, self, h['txid'] end end |