Class: Protor::UDPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/protor/udp_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, formatter) ⇒ UDPClient

Returns a new instance of UDPClient.



7
8
9
10
11
# File 'lib/protor/udp_client.rb', line 7

def initialize(host, port, formatter)
  @port = port
  @host = host
  @formatter = formatter
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/protor/udp_client.rb', line 5

def connection
  @connection
end

#formatterObject (readonly)

Returns the value of attribute formatter.



5
6
7
# File 'lib/protor/udp_client.rb', line 5

def formatter
  @formatter
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/protor/udp_client.rb', line 5

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/protor/udp_client.rb', line 5

def port
  @port
end

Instance Method Details

#publish(payload) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/protor/udp_client.rb', line 13

def publish(payload)
  connect do |conn|
    formatter.format(payload) do |msg|
      conn.send(msg, 0)
    end
  end
end