Class: Roby::Distributed::Peer::DRoby

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/distributed/protocol.rb

Overview

An intermediate representation of Peer objects suitable to be sent to our peers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, peer_id) ⇒ DRoby

Returns a new instance of DRoby.



269
# File 'lib/roby/distributed/protocol.rb', line 269

def initialize(name, peer_id); @name, @peer_id = name, peer_id end

Instance Attribute Details

#nameObject (readonly)

:nodoc:



268
269
270
# File 'lib/roby/distributed/protocol.rb', line 268

def name
  @name
end

#peer_idObject (readonly)

:nodoc:



268
269
270
# File 'lib/roby/distributed/protocol.rb', line 268

def peer_id
  @peer_id
end

Instance Method Details

#eql?(obj) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


271
# File 'lib/roby/distributed/protocol.rb', line 271

def eql?(obj); obj.respond_to?(:peer_id) && peer_id == obj.peer_id end

#hashObject



270
# File 'lib/roby/distributed/protocol.rb', line 270

def hash; peer_id.hash end

#proxy(peer) ⇒ Object



275
276
277
278
279
280
281
# File 'lib/roby/distributed/protocol.rb', line 275

def proxy(peer)
    if peer = Distributed.peer(peer_id)
	peer
    else
	raise "unknown peer ID #{peer_id}, known peers are #{Distributed.peers}"
    end
end

#to_sObject



274
# File 'lib/roby/distributed/protocol.rb', line 274

def to_s; "#<dRoby:Peer #{name} #{peer_id}>" end