Class: PioneerRubySdk
- Inherits:
-
Object
- Object
- PioneerRubySdk
- Defined in:
- lib/pioneer_ruby_sdk.rb
Overview
wrapper for event source client
Instance Method Summary collapse
- #connect ⇒ Object
- #get_feature(key, default_value = nil) ⇒ Object
- #get_server_address ⇒ Object
-
#initialize(server_address, sdk_key) ⇒ PioneerRubySdk
constructor
A new instance of PioneerRubySdk.
- #with_context(user_key) ⇒ Object
- #with_wait_for_data ⇒ Object
Constructor Details
#initialize(server_address, sdk_key) ⇒ PioneerRubySdk
Returns a new instance of PioneerRubySdk.
7 8 9 10 11 12 13 14 |
# File 'lib/pioneer_ruby_sdk.rb', line 7 def initialize(server_address, sdk_key) @server_address = server_address @sdk_key = sdk_key @configs = { server_address: @server_address, sdk_key: @sdk_key } end |
Instance Method Details
#connect ⇒ Object
16 17 18 19 20 |
# File 'lib/pioneer_ruby_sdk.rb', line 16 def connect() @client = EventSourceClient.new(@configs) @client.start self end |
#get_feature(key, default_value = nil) ⇒ Object
54 55 56 |
# File 'lib/pioneer_ruby_sdk.rb', line 54 def get_feature(key, default_value = nil) @client.get_feature(key, default_value) end |
#get_server_address ⇒ Object
50 51 52 |
# File 'lib/pioneer_ruby_sdk.rb', line 50 def get_server_address() return @server_address end |
#with_context(user_key) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/pioneer_ruby_sdk.rb', line 40 def with_context(user_key) context_obj = { context: Context.new(user_key), client: @client, config: @configs } return ClientWithContext.new(context_obj) end |
#with_wait_for_data ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pioneer_ruby_sdk.rb', line 22 def with_wait_for_data() time_out = 1 polling_attempts = 10 attempts = 0 until @client.has_data() do attempts += 1 if attempts > polling_attempts puts "Cannot connect to Scout, connection timed out" @client.close() break end puts 'Attempting to connect to scout daemon...' end return self end |