Class: DHT::Node
- Inherits:
-
Object
- Object
- DHT::Node
- Defined in:
- lib/dht/node.rb
Instance Method Summary collapse
- #configuration ⇒ Object
-
#initialize(options = {}) ⇒ Node
constructor
A new instance of Node.
- #key ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Node
Returns a new instance of Node.
11 12 13 14 15 16 17 18 19 |
# File 'lib/dht/node.rb', line 11 def initialize( = {}) = .merge() @host = .delete(:host) @port = .delete(:port) @name = .delete(:name) @node = .delete(:node) @explorer = .delete(:explorer) end |
Instance Method Details
#configuration ⇒ Object
26 27 28 29 30 31 |
# File 'lib/dht/node.rb', line 26 def configuration configuration = {:id => @name, :addr => "tcp://#{@host}:#{@port}"} configuration.merge!(:directory => @node) if @node configuration end |
#key ⇒ Object
33 34 35 |
# File 'lib/dht/node.rb', line 33 def key @key ||= Key.for_content("#{@name}:#{@host}:#{@port}") end |
#start ⇒ Object
21 22 23 24 |
# File 'lib/dht/node.rb', line 21 def start DCell.start(configuration) DHT::Service.new(:key => key, :explorer => @explorer).run end |