Class: Peasant::Node

Inherits:
Object
  • Object
show all
Includes:
NodeCallbacks
Defined in:
lib/peasant/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 options={}
  @load = 0
  @host, @port = options[:host], options[:port]
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/peasant/node.rb', line 5

def host
  @host
end

#loadObject

Returns the value of attribute load.



6
7
8
# File 'lib/peasant/node.rb', line 6

def load
  @load
end

#portObject (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_counterObject



17
18
19
# File 'lib/peasant/node.rb', line 17

def decrement_counter
  self.load -= 1
end

#increment_counterObject



13
14
15
# File 'lib/peasant/node.rb', line 13

def increment_counter
  self.load += 1
end

#to_sObject



21
22
23
# File 'lib/peasant/node.rb', line 21

def to_s
  "#{host}:#{port}"
end