Class: SchwabRb::Stream::Client
- Inherits:
-
Object
- Object
- SchwabRb::Stream::Client
- Defined in:
- lib/schwab_rb/stream/client.rb
Instance Method Summary collapse
- #connected? ⇒ Boolean
-
#initialize(client) ⇒ Client
constructor
A new instance of Client.
- #on(service_symbol, symbols: nil, fields: nil, &block) ⇒ Object
- #start ⇒ Object
- #start_async ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(client) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/schwab_rb/stream/client.rb', line 9 def initialize(client) @stream = Base.new(client) @thread = nil end |
Instance Method Details
#connected? ⇒ Boolean
39 40 41 |
# File 'lib/schwab_rb/stream/client.rb', line 39 def connected? @stream.connected? end |
#on(service_symbol, symbols: nil, fields: nil, &block) ⇒ Object
14 15 16 17 |
# File 'lib/schwab_rb/stream/client.rb', line 14 def on(service_symbol, symbols: nil, fields: nil, &block) @stream.on(service_symbol, symbols: symbols, fields: fields, &block) self end |
#start ⇒ Object
19 20 21 22 23 24 |
# File 'lib/schwab_rb/stream/client.rb', line 19 def start @thread = Thread.new do @stream.start end @thread.join end |
#start_async ⇒ Object
26 27 28 29 30 31 |
# File 'lib/schwab_rb/stream/client.rb', line 26 def start_async @thread = Thread.new do @stream.start end self end |
#stop ⇒ Object
33 34 35 36 37 |
# File 'lib/schwab_rb/stream/client.rb', line 33 def stop @stream.stop @thread&.join(5) @thread = nil end |