Class: WebhookStopwatch::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/webhook_stopwatch/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(redis_or_url) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
# File 'lib/webhook_stopwatch/client.rb', line 8

def initialize(redis_or_url)
  if redis_or_url.is_a?(String)
    @redis = Redis.new(:url => redis_or_url)
  else
    @redis = redis_or_url
  end
end

Instance Attribute Details

#redisObject (readonly)

Returns the value of attribute redis.



6
7
8
# File 'lib/webhook_stopwatch/client.rb', line 6

def redis
  @redis
end

Instance Method Details

#pingObject



24
25
26
# File 'lib/webhook_stopwatch/client.rb', line 24

def ping
  publish(encode_json({}))
end

#start(message_id, timestamp) ⇒ Object



16
17
18
# File 'lib/webhook_stopwatch/client.rb', line 16

def start(message_id, timestamp)
  publish_event("start", message_id, timestamp)
end

#stop(message_id, timestamp) ⇒ Object



20
21
22
# File 'lib/webhook_stopwatch/client.rb', line 20

def stop(message_id, timestamp)
  publish_event("stop", message_id, timestamp)
end