Class: Zold::List
- Inherits:
-
Object
- Object
- Zold::List
- Includes:
- ThreadBadge
- Defined in:
- lib/zold/commands/list.rb
Overview
LIST command
Instance Method Summary collapse
-
#initialize(wallets:, copies:, log: Loog::NULL) ⇒ List
constructor
A new instance of List.
- #run(_ = []) ⇒ Object
Constructor Details
#initialize(wallets:, copies:, log: Loog::NULL) ⇒ List
Returns a new instance of List.
21 22 23 24 25 |
# File 'lib/zold/commands/list.rb', line 21 def initialize(wallets:, copies:, log: Loog::NULL) @wallets = wallets @copies = copies @log = log end |
Instance Method Details
#run(_ = []) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/zold/commands/list.rb', line 27 def run(_ = []) total = 0 txns = 0 size = 0 balance = Amount::ZERO @wallets.all.sort.each do |id| total += 1 cps = Copies.new(File.join(@copies, id)) @wallets.acq(id) do |wallet| msg = "#{wallet.mnemo} #{cps.all.count}c" msg += " (net:#{wallet.network})" if wallet.network != Wallet::MAINET txns += wallet.txns.count balance += wallet.balance size += wallet.size @log.info(msg) end end @log.info("#{total} wallets, #{txns} transactions, #{Size.new(size)}, #{balance} in total") end |