Sha256: d5c7da1789ace07821f82d865fd6a868f1e8aa8fae082266992f389838e869ad

Contents?: true

Size: 769 Bytes

Versions: 6

Compression:

Stored size: 769 Bytes

Contents

# encoding: utf-8

module Github
  module Result

    RATELIMIT = 'X-RateLimit-Remaining'.freeze
    CONTENT_TYPE = 'Content-Type'.freeze
    CONTENT_LENGTH = 'content-length'.freeze

    attr_reader :env

    # Requests are limited to API v3 to 5000 per hour.
    def ratelimit
      loaded? ? @env[:response_headers][RATELIMIT] : nil
    end

    def content_type
      loaded? ? @env[:response_headers][CONTENT_TYPE] : nil
    end

    def content_length
      loaded? ? @env[:response_headers][CONTENT_LENGTH] : nil
    end

    def status
      loaded? ? @env[:status] : nil
    end

    def success?
      (200..299).include? status
    end

    def body
      loaded? ? @env[:body] : nil
    end

    def loaded?
      !!env
    end

  end # Result
end # Github

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
github_api-0.3.9 lib/github_api/result.rb
github_api-0.3.8 lib/github_api/result.rb
github_api-0.3.7 lib/github_api/result.rb
github_api-0.3.6 lib/github_api/result.rb
github_api-0.3.4 lib/github_api/result.rb
github_api-0.3.3 lib/github_api/result.rb