Class: DHT::Hash
- Inherits:
-
Object
- Object
- DHT::Hash
- Defined in:
- lib/dht/hash.rb,
lib/dht/version.rb
Constant Summary collapse
- VERSION =
'0.0.1'
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(options = {}) ⇒ Hash
constructor
A new instance of Hash.
- #manager ⇒ Object
- #me ⇒ Object
- #storage ⇒ Object
- #store(key, value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Hash
Returns a new instance of Hash.
7 8 9 10 |
# File 'lib/dht/hash.rb', line 7 def initialize( = {}) @node = DHT::Node.new() @node.start end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
5 6 7 |
# File 'lib/dht/hash.rb', line 5 def node @node end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/dht/hash.rb', line 36 def [](key) get(key) end |
#[]=(key, value) ⇒ Object
32 33 34 |
# File 'lib/dht/hash.rb', line 32 def []=(key, value) store(key, value) end |
#get(key) ⇒ Object
28 29 30 |
# File 'lib/dht/hash.rb', line 28 def get(key) manager.storage_for(key).get(key) end |
#manager ⇒ Object
20 21 22 |
# File 'lib/dht/hash.rb', line 20 def manager me[:manager] end |
#me ⇒ Object
12 13 14 |
# File 'lib/dht/hash.rb', line 12 def me DCell.me end |
#storage ⇒ Object
16 17 18 |
# File 'lib/dht/hash.rb', line 16 def storage me[:storage] end |
#store(key, value) ⇒ Object
24 25 26 |
# File 'lib/dht/hash.rb', line 24 def store(key, value) manager.storage_for(key).store(key, value) end |