Class: ConsistentHashing::Anchor
- Inherits:
-
Object
- Object
- ConsistentHashing::Anchor
- Defined in:
- lib/consistent_hashing.rb
Instance Attribute Summary collapse
-
#server ⇒ Object
Returns the value of attribute server.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other_anchor) ⇒ Object
-
#initialize(value, server) ⇒ Anchor
constructor
A new instance of Anchor.
- #inspect ⇒ Object
- #to_s ⇒ Object
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
#server ⇒ Object
Returns the value of attribute server.
7 8 9 |
# File 'lib/consistent_hashing.rb', line 7 def server @server end |
#value ⇒ Object
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 |
#inspect ⇒ Object
22 23 24 |
# File 'lib/consistent_hashing.rb', line 22 def inspect "<ConsistentHashing::Anchor | #{self}>" end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/consistent_hashing.rb', line 18 def to_s "value:#{value}, server:#{server.address}" end |