lib/deribit/ws/handler.rb in deribit-1.3.2 vs lib/deribit/ws/handler.rb in deribit-1.4.3
- old
+ new
@@ -1,10 +1,9 @@
module Deribit
class WS
-
class Handler
- attr_accessor :timestamp
+ attr_reader :timestamp
AVAILABLE_METHODS = [
:account,
:getcurrencies,
:subscribe,
@@ -23,14 +22,10 @@
:order,
:pong
]
SILENT = [:setheartbeat, :subscribed, :heartbeat, :"public API test"]
- def initialize
- @timestamp = Time.now.to_i
- end
-
def method_missing(m, *json, &block)
return false if SILENT.include?(m.to_sym)
puts "Delegating #{m}"
if AVAILABLE_METHODS.include?(m.to_sym)
@@ -47,9 +42,13 @@
puts "Notice: #{msg}" if msg && !SILENT.include?(msg.to_sym)
end
def handle_error(json, error)
puts "Alert! #{error.class} on message: '#{json.try(:fetch, :message)}', #{json.inspect}. Message: #{error.full_message}"
+ end
+
+ def update_timestamp!
+ @timestamp = Time.now.to_i
end
end
end
end