Class: Protor::UDPClient
- Inherits:
-
Object
- Object
- Protor::UDPClient
- Defined in:
- lib/protor/udp_client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(host, port, formatter) ⇒ UDPClient
constructor
A new instance of UDPClient.
- #publish(payload) ⇒ Object
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
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/protor/udp_client.rb', line 5 def connection @connection end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
5 6 7 |
# File 'lib/protor/udp_client.rb', line 5 def formatter @formatter end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/protor/udp_client.rb', line 5 def host @host end |
#port ⇒ Object (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 |