Class: Kedama::Nodes

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

Overview

ConsitentHash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNodes

Returns a new instance of Nodes.



87
88
89
# File 'lib/kedama.rb', line 87

def initialize
  @nodes = {}
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



85
86
87
# File 'lib/kedama.rb', line 85

def nodes
  @nodes
end

Instance Method Details

#add(name, weight = 1) ⇒ Object



91
92
93
# File 'lib/kedama.rb', line 91

def add(name, weight = 1)
  @nodes[name.to_str] = weight.to_int
end

#delete(name) ⇒ Object



95
96
97
# File 'lib/kedama.rb', line 95

def delete(name)
  @nodes.delete(name)
end

#to_hObject



99
100
101
# File 'lib/kedama.rb', line 99

def to_h
  ConsitentHash.new(@nodes)
end