Class: Buschtelefon::RemoteTattler
- Inherits:
-
Object
- Object
- Buschtelefon::RemoteTattler
- Defined in:
- lib/buschtelefon/remote_tattler.rb
Overview
No need to inheritance from Tattler because not all its features are available here (only #feed)
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #feed(gossip) ⇒ Object
-
#initialize(host:, port:, outbound_socket: UDPSocket.new) ⇒ RemoteTattler
constructor
A new instance of RemoteTattler.
- #inquire ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(host:, port:, outbound_socket: UDPSocket.new) ⇒ RemoteTattler
Returns a new instance of RemoteTattler.
8 9 10 11 12 |
# File 'lib/buschtelefon/remote_tattler.rb', line 8 def initialize(host:, port:, outbound_socket: UDPSocket.new) @host = host @port = port @outbound_socket = outbound_socket end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/buschtelefon/remote_tattler.rb', line 6 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/buschtelefon/remote_tattler.rb', line 6 def port @port end |
Instance Method Details
#feed(gossip) ⇒ Object
14 15 16 17 |
# File 'lib/buschtelefon/remote_tattler.rb', line 14 def feed(gossip) # puts "#{@outbound_socket.local_address.ip_port} sending #{JSON.parse(gossip.message)['number']} to #{@port}" @outbound_socket.send(gossip., 0, @host, @port) end |
#inquire ⇒ Object
19 20 21 |
# File 'lib/buschtelefon/remote_tattler.rb', line 19 def inquire @outbound_socket.send("\x05", 0, @host, @port) end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/buschtelefon/remote_tattler.rb', line 23 def to_s "#{@host}:#{@port}" end |