Module: NanoRpc::AccountsHelper
- Includes:
- ApplicationHelper
- Included in:
- Accounts
- Defined in:
- lib/nano_rpc/helpers/accounts_helper.rb
Instance Method Summary collapse
- #<<(val) ⇒ Object
-
#[](idx) ⇒ Object
Array-like access for NanoRpc::Account.
- #balances ⇒ Object
- #each(&_block) ⇒ Object
- #first ⇒ Object
- #frontiers ⇒ Object
- #last ⇒ Object
- #move(from:, to:) ⇒ Object
- #pending(count:, threshold: nil, source: nil) ⇒ Object (also: #pending_blocks)
- #pending_balances ⇒ Object (also: #balances_pending)
- #second ⇒ Object
- #size ⇒ Object
- #third ⇒ Object
Instance Method Details
#<<(val) ⇒ Object
46 47 48 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 46 def <<(val) @addresses << val end |
#[](idx) ⇒ Object
Array-like access for NanoRpc::Account
40 41 42 43 44 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 40 def [](idx) return unless @addresses[idx] @account_objects ||= [] @account_objects[idx] ||= NanoRpc::Account.new(@addresses[idx], node: node) end |
#balances ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 5 def balances accounts_balances .balances .each_with_object({}) do |(k, v), hash| hash[k] = v['balance'] end end |
#each(&_block) ⇒ Object
50 51 52 53 54 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 50 def each(&_block) @addresses.each do |address| yield NanoRpc::Account.new(address, node: node) end end |
#first ⇒ Object
56 57 58 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 56 def first self[0] end |
#frontiers ⇒ Object
22 23 24 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 22 def frontiers accounts_frontiers.frontiers end |
#last ⇒ Object
68 69 70 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 68 def last self[-1] end |
#move(from:, to:) ⇒ Object
26 27 28 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 26 def move(from:, to:) account_move(source: from, wallet: to).moved == 1 end |
#pending(count:, threshold: nil, source: nil) ⇒ Object Also known as: pending_blocks
30 31 32 33 34 35 36 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 30 def pending(count:, threshold: nil, source: nil) accounts_pending( count: count, threshold: threshold, source: source ).blocks end |
#pending_balances ⇒ Object Also known as: balances_pending
13 14 15 16 17 18 19 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 13 def pending_balances accounts_balances .balances .each_with_object({}) do |(k, v), hash| hash[k] = v['pending'] end end |
#second ⇒ Object
60 61 62 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 60 def second self[1] end |
#size ⇒ Object
72 73 74 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 72 def size addresses.size end |
#third ⇒ Object
64 65 66 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 64 def third self[2] end |