Class: Slash7::Client
- Inherits:
-
Object
- Object
- Slash7::Client
- Defined in:
- lib/slash7/client.rb
Constant Summary collapse
- SERVER =
'tracker.slash-7.com'
Class Method Summary collapse
Instance Method Summary collapse
- #endpoint_url ⇒ Object
-
#initialize(tracing_code, options = {}) ⇒ Client
constructor
Initialize SLASH-7 client.
-
#send_data(data) ⇒ Object
Send data to SLASH-7.
- #server ⇒ Object
Constructor Details
#initialize(tracing_code, options = {}) ⇒ Client
Initialize SLASH-7 client
14 15 16 17 |
# File 'lib/slash7/client.rb', line 14 def initialize(tracing_code, = {}) @tracing_code = tracing_code @options = end |
Class Method Details
.encode(data) ⇒ Object
36 37 38 |
# File 'lib/slash7/client.rb', line 36 def encode(data) Base64.encode64(data.to_json) end |
Instance Method Details
#endpoint_url ⇒ Object
26 27 28 |
# File 'lib/slash7/client.rb', line 26 def endpoint_url "http://#{server}/track/#@tracing_code" end |
#send_data(data) ⇒ Object
Send data to SLASH-7. See p-lucky.atlassian.net/wiki/display/PUB/Event+log+format for the format.
22 23 24 |
# File 'lib/slash7/client.rb', line 22 def send_data(data) Net::HTTP.post_form(URI.parse(endpoint_url), {'data' => self.class.encode(data)}) end |
#server ⇒ Object
30 31 32 |
# File 'lib/slash7/client.rb', line 30 def server @options[:server] || SERVER end |