Class: Fyrehose::AbstractClient
- Inherits:
-
Object
- Object
- Fyrehose::AbstractClient
- Defined in:
- lib/fyrehose/abstract_client.rb
Constant Summary collapse
- TIMEOUT =
0.1
Instance Method Summary collapse
- #deliver(channel, data) ⇒ Object
-
#initialize(host, port, opts = {}) ⇒ AbstractClient
constructor
A new instance of AbstractClient.
Constructor Details
#initialize(host, port, opts = {}) ⇒ AbstractClient
Returns a new instance of AbstractClient.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fyrehose/abstract_client.rb', line 5 def initialize(host, port, opts = {}) @host = host @port = port @opts = opts @timeout = if opts[:timeout] opts[:timeout].to_f else TIMEOUT end end |
Instance Method Details
#deliver(channel, data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fyrehose/abstract_client.rb', line 17 def deliver(channel, data) channel = channel.to_s data = data.to_s if channel.include?(" ") raise Fyrehose::Error.new("channel names must not include whitespace") end txid = Fyrehose.next_txid send_data("##{txid} @#{channel} *#{data.size} #{data}\n") end |