Class: Peasant::Node
- Inherits:
-
Object
- Object
- Peasant::Node
- Includes:
- NodeCallbacks
- Defined in:
- lib/peasant/node.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#load ⇒ Object
Returns the value of attribute load.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #decrement_counter ⇒ Object
- #increment_counter ⇒ Object
-
#initialize(options = {}) ⇒ Node
constructor
A new instance of Node.
- #to_s ⇒ Object
Methods included from NodeCallbacks
#assign_callbacks_to, #on_connect, #on_connect_cb, #on_data, #on_data_cb, #on_finish, #on_finish_cb, #on_response, #on_response_cb, #on_select, #on_select_cb
Constructor Details
#initialize(options = {}) ⇒ Node
Returns a new instance of Node.
8 9 10 11 |
# File 'lib/peasant/node.rb', line 8 def initialize ={} @load = 0 @host, @port = [:host], [:port] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/peasant/node.rb', line 5 def host @host end |
#load ⇒ Object
Returns the value of attribute load.
6 7 8 |
# File 'lib/peasant/node.rb', line 6 def load @load end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/peasant/node.rb', line 5 def port @port end |
Instance Method Details
#decrement_counter ⇒ Object
17 18 19 |
# File 'lib/peasant/node.rb', line 17 def decrement_counter self.load -= 1 end |
#increment_counter ⇒ Object
13 14 15 |
# File 'lib/peasant/node.rb', line 13 def increment_counter self.load += 1 end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/peasant/node.rb', line 21 def to_s "#{host}:#{port}" end |