Class: Zold::Propagate

Inherits:
Object
  • Object
show all
Includes:
ThreadBadge
Defined in:
lib/zold/commands/propagate.rb

Overview

PROPAGATE pulling command

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, log: Log::NULL) ⇒ Propagate

Returns a new instance of Propagate.



42
43
44
45
# File 'lib/zold/commands/propagate.rb', line 42

def initialize(wallets:, log: Log::NULL)
  @wallets = wallets
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object

Returns list of Wallet IDs which were affected



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/zold/commands/propagate.rb', line 48

def run(args = [])
  @log.debug("Propagate.run(#{args.join(' ')})")
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold propagate [ID...] [options]
Available options:"
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  modified = []
  (mine.empty? ? @wallets.all : mine.map { |i| Id.new(i) }).each do |id|
    modified += propagate(id, opts)
  end
  modified
end