Sha256: 4e6987c14177dff91efaa987936442e0642e3f69a00b2cdf8093b28144ea1e90

Contents?: true

Size: 687 Bytes

Versions: 4

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

require_relative 'util'

class Nanook
  # The <tt>Nanook::WorkPeer</tt> class lets you manage your node's work peers.
  class WorkPeer
    include Nanook::Util

    def initialize(rpc)
      @rpc = rpc
    end

    def add(address:, port:)
      rpc(:work_peer_add, address: address, port: port).key?(:success)
    end

    def clear
      rpc(:work_peers_clear).key?(:success)
    end

    # @return [String]
    def to_s
      self.class.name
    end
    alias inspect to_s

    def list
      rpc(:work_peers, _access: :work_peers, _coerce: Array)
    end

    private

    def rpc(action, params = {})
      @rpc.call(action, params)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nanook-4.0.0 lib/nanook/work_peer.rb
nanook-3.1.0 lib/nanook/work_peer.rb
nanook-3.0.1 lib/nanook/work_peer.rb
nanook-3.0.0 lib/nanook/work_peer.rb