Class: Roby::DRoby::V5::RemoteDRobyID

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/droby/v5/remote_droby_id.rb

Overview

Cross-instance identification of an object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(peer_id, droby_id) ⇒ RemoteDRobyID

Returns a new instance of RemoteDRobyID.



24
25
26
27
28
29
# File 'lib/roby/droby/v5/remote_droby_id.rb', line 24

def initialize(peer_id, droby_id)
    @peer_id = peer_id
    @droby_id = droby_id

    @hash = [@peer_id, @droby_id].hash
end

Instance Attribute Details

#droby_idDRobyID (readonly)

The object ID

Returns:



16
17
18
# File 'lib/roby/droby/v5/remote_droby_id.rb', line 16

def droby_id
  @droby_id
end

#hashObject (readonly)

The ID hash value

The values are immutable, so the hash value is computed once and cached here



22
23
24
# File 'lib/roby/droby/v5/remote_droby_id.rb', line 22

def hash
  @hash
end

#peer_idPeerID (readonly)

The peer on which the object is known as #droby_id

Returns:



11
12
13
# File 'lib/roby/droby/v5/remote_droby_id.rb', line 11

def peer_id
  @peer_id
end

Instance Method Details

#==(other) ⇒ Object



37
38
39
# File 'lib/roby/droby/v5/remote_droby_id.rb', line 37

def ==(other)
    eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/roby/droby/v5/remote_droby_id.rb', line 31

def eql?(other)
    other.kind_of?(RemoteDRobyID) &&
        other.peer_id == peer_id &&
        other.droby_id == droby_id
end

#to_sObject



41
42
43
# File 'lib/roby/droby/v5/remote_droby_id.rb', line 41

def to_s
    "#<RemoteDRobyID #{peer_id}@#{droby_id}>"
end