Class: DHT::Storage
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(key) ⇒ Storage
constructor
A new instance of Storage.
- #store(key, value) ⇒ Object
Constructor Details
#initialize(key) ⇒ Storage
Returns a new instance of Storage.
9 10 11 12 |
# File 'lib/dht/storage.rb', line 9 def initialize(key) @key = key @database = {} end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
7 8 9 |
# File 'lib/dht/storage.rb', line 7 def database @database end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/dht/storage.rb', line 7 def key @key end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 |
# File 'lib/dht/storage.rb', line 22 def [](key) get(key) end |
#[]=(key, value) ⇒ Object
26 27 28 |
# File 'lib/dht/storage.rb', line 26 def []=(key, value) store(key, value) end |
#get(key) ⇒ Object
18 19 20 |
# File 'lib/dht/storage.rb', line 18 def get(key) @database[key] end |
#store(key, value) ⇒ Object
14 15 16 |
# File 'lib/dht/storage.rb', line 14 def store(key, value) @database[key] = value end |