Class: ConsistentHashing::Anchor

Inherits:
Object
  • Object
show all
Defined in:
lib/consistent_hashing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, server) ⇒ Anchor

Returns a new instance of Anchor.



9
10
11
12
# File 'lib/consistent_hashing.rb', line 9

def initialize(value, server)
  @value = value
  @server = server
end

Instance Attribute Details

#serverObject

Returns the value of attribute server.



7
8
9
# File 'lib/consistent_hashing.rb', line 7

def server
  @server
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/consistent_hashing.rb', line 7

def value
  @value
end

Instance Method Details

#<=>(other_anchor) ⇒ Object



14
15
16
# File 'lib/consistent_hashing.rb', line 14

def <=>(other_anchor)
  value <=> other_anchor.value
end

#inspectObject



22
23
24
# File 'lib/consistent_hashing.rb', line 22

def inspect
  "<ConsistentHashing::Anchor | #{self}>"
end

#to_sObject



18
19
20
# File 'lib/consistent_hashing.rb', line 18

def to_s
  "value:#{value}, server:#{server.address}"
end