Class: Kedama::Nodes
- Inherits:
-
Object
- Object
- Kedama::Nodes
- Defined in:
- lib/kedama.rb
Overview
ConsitentHash
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #add(name, weight = 1) ⇒ Object
- #delete(name) ⇒ Object
-
#initialize ⇒ Nodes
constructor
A new instance of Nodes.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Nodes
Returns a new instance of Nodes.
87 88 89 |
# File 'lib/kedama.rb', line 87 def initialize @nodes = {} end |
Instance Attribute Details
#nodes ⇒ Object (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_h ⇒ Object
99 100 101 |
# File 'lib/kedama.rb', line 99 def to_h ConsitentHash.new(@nodes) end |