Sha256: 886bd5fb127b1de8dd72a8268bfe07fdb39d01d912d0497523395165b6ce8c15
Contents?: true
Size: 995 Bytes
Versions: 4
Compression:
Stored size: 995 Bytes
Contents
module AngellistApi # Custom error class for rescuing from all AngellistApi errors class Error < StandardError attr_reader :http_headers # Initializes new Error object # # @param [String] message # @param [Hash] http_headers # @return [AngellistApi::Error] def initialize(message, http_headers) @http_headers = Hash[http_headers] super message end # @return [Time] def ratelimit_reset Time.at(@http_headers.values_at('x-ratelimit-reset', 'X-RateLimit-Reset').detect{|value| value}.to_i) end # @return [Integer] def ratelimit_limit @http_headers.values_at('x-ratelimit-limit', 'X-RateLimit-Limit').detect{|value| value}.to_i end # @return [Integer] def ratelimit_remaining @http_headers.values_at('x-ratelimit-remaining', 'X-RateLimit-Remaining').detect{|value| value}.to_i end # @return [Integer] def retry_after [(ratelimit_reset - Time.now).ceil, 0].max end end end
Version data entries
4 entries across 4 versions & 1 rubygems