Class: Hatchet::ShellThrottle::FakeResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/shell_throttle.rb

Overview

Helper class to be used along with the PlatformAPI.rate_throttle interface that expects a response object

Example:

FakeResponse.new(status: 200, remaining: 2).status #=> 200
FakeResponse.new(status: 200, remaining: 2).headers["RateLimit-Remaining"] #=> 2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, remaining:) ⇒ FakeResponse

Returns a new instance of FakeResponse.



60
61
62
63
64
65
66
67
68
# File 'lib/hatchet/shell_throttle.rb', line 60

def initialize(status:, remaining: )
  @status = status

  @headers = {
    "RateLimit-Remaining" => remaining,
    "RateLimit-Multiplier" => 1,
    "Content-Type" => "text/plain".freeze
  }
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



58
59
60
# File 'lib/hatchet/shell_throttle.rb', line 58

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



58
59
60
# File 'lib/hatchet/shell_throttle.rb', line 58

def status
  @status
end