Class: SDM::RateLimitMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

RateLimitMetadata contains information about remaining requests avaialable to the user over some timeframe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket: nil, limit: nil, remaining: nil, reset_at: nil) ⇒ RateLimitMetadata



13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
# File 'lib/models/porcelain.rb', line 13717

def initialize(
  bucket: nil,
  limit: nil,
  remaining: nil,
  reset_at: nil
)
  @bucket = bucket == nil ? "" : bucket
  @limit = limit == nil ? 0 : limit
  @remaining = remaining == nil ? 0 : remaining
  @reset_at = reset_at == nil ? nil : reset_at
end

Instance Attribute Details

#bucketObject

The bucket this user/token is associated with, which may be shared between multiple users/tokens.



13708
13709
13710
# File 'lib/models/porcelain.rb', line 13708

def bucket
  @bucket
end

#limitObject

How many total requests the user/token is authorized to make before being rate limited.



13711
13712
13713
# File 'lib/models/porcelain.rb', line 13711

def limit
  @limit
end

#remainingObject

How many remaining requests out of the limit are still avaialable.



13713
13714
13715
# File 'lib/models/porcelain.rb', line 13713

def remaining
  @remaining
end

#reset_atObject

The time when remaining will be reset to limit.



13715
13716
13717
# File 'lib/models/porcelain.rb', line 13715

def reset_at
  @reset_at
end

Instance Method Details

#to_json(options = {}) ⇒ Object



13729
13730
13731
13732
13733
13734
13735
# File 'lib/models/porcelain.rb', line 13729

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end