Class: KrakenClient::Requests::Limiter

Inherits:
Object
  • Object
show all
Defined in:
lib/kraken_client/requests/limiter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Limiter

Returns a new instance of Limiter.



7
8
9
10
11
# File 'lib/kraken_client/requests/limiter.rb', line 7

def initialize(config)
  @config              = config
  @previous_timestamps = Time.now
  @current_count       = counter_total
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/kraken_client/requests/limiter.rb', line 5

def config
  @config
end

#current_countObject (readonly)

Returns the value of attribute current_count.



5
6
7
# File 'lib/kraken_client/requests/limiter.rb', line 5

def current_count
  @current_count
end

#endpoint_nameObject (readonly)

Returns the value of attribute endpoint_name.



5
6
7
# File 'lib/kraken_client/requests/limiter.rb', line 5

def endpoint_name
  @endpoint_name
end

#previous_timestampsObject (readonly)

Returns the value of attribute previous_timestamps.



5
6
7
# File 'lib/kraken_client/requests/limiter.rb', line 5

def previous_timestamps
  @previous_timestamps
end

Instance Method Details

#update(endpoint_name) ⇒ Object



13
14
15
16
17
18
# File 'lib/kraken_client/requests/limiter.rb', line 13

def update(endpoint_name)
  return unless config.limiter
  @endpoint_name = endpoint_name

  decrement_current_count
end