Class: Zold::Pull
- Inherits:
-
Object
- Object
- Zold::Pull
- Defined in:
- lib/zold/commands/pull.rb
Overview
Wallet pulling command
Instance Method Summary collapse
-
#initialize(wallet:, log: Log::Quiet.new) ⇒ Pull
constructor
A new instance of Pull.
- #run ⇒ Object
Constructor Details
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/zold/commands/pull.rb', line 35 def run request = Net::HTTP::Get.new("/wallets/#{@wallet.id}") response = Net::HTTP.new('b1.zold.io', 80).start do |http| http.request(request) end unless response.code.to_i == 200 raise "Failed to pull from the the node, code=#{response.code}" end File.write(@wallet.path, response.body) @log.info("The #{@wallet} pulled from the server") @wallet end |