Class: ItsyBtc::Commands::BalanceCommand
- Defined in:
- lib/itsy-btc/commands/balance_command.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from Command
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/itsy-btc/commands/balance_command.rb', line 7 def run if @wallet.nil? puts "No wallet found! Use `itsy init` to create one." exit end entries = @wallet.entries if entries.empty? puts "This wallet has no addresses." else total = entries.map { |e| Lookup.balance(e.address) || exit }.inject(:+) puts ItsyBtc.format_value(total) + " BTC" end end |