Class: Github::Response::Header

Inherits:
Struct
  • Object
show all
Includes:
Constants
Defined in:
lib/github_api2/response/header.rb

Overview

Represents http response header

Constant Summary collapse

SUCCESSFUL_STATUSES =
200..299

Constants included from Constants

Constants::ACCEPT, Constants::ACCEPTED_OAUTH_SCOPES, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::OAUTH_SCOPES, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::RATELIMIT_RESET, Constants::SERVER, Constants::USER_AGENT

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject

Returns the value of attribute env

Returns:

  • (Object)

    the current value of env



9
10
11
# File 'lib/github_api2/response/header.rb', line 9

def env
  @env
end

Instance Method Details

#[](property) ⇒ Object



18
19
20
# File 'lib/github_api2/response/header.rb', line 18

def [](property)
  loaded? ? env[:response_headers][property] : nil
end

#accepted_oauth_scopesObject



26
27
28
# File 'lib/github_api2/response/header.rb', line 26

def accepted_oauth_scopes
  loaded? ? env[:response_headers][ACCEPTED_OAUTH_SCOPES] : nil
end

#bodyObject

Returns raw body



82
83
84
# File 'lib/github_api2/response/header.rb', line 82

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

#cache_controlObject



45
46
47
# File 'lib/github_api2/response/header.rb', line 45

def cache_control
  loaded? ? env[:response_headers][CACHE_CONTROL] : nil
end

#content_lengthObject



53
54
55
# File 'lib/github_api2/response/header.rb', line 53

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

#content_typeObject



49
50
51
# File 'lib/github_api2/response/header.rb', line 49

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

#dateObject



61
62
63
# File 'lib/github_api2/response/header.rb', line 61

def date
  loaded? ? env[:response_headers][DATE] : nil
end

#etagObject



57
58
59
# File 'lib/github_api2/response/header.rb', line 57

def etag
  loaded? ? env[:response_headers][ETAG] : nil
end

#loaded?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/github_api2/response/header.rb', line 14

def loaded?
  !!env
end

#locationObject



65
66
67
# File 'lib/github_api2/response/header.rb', line 65

def location
  loaded? ? env[:response_headers][LOCATION] : nil
end

#oauth_scopesObject



22
23
24
# File 'lib/github_api2/response/header.rb', line 22

def oauth_scopes
  loaded? ? env[:response_headers][OAUTH_SCOPES] : nil
end

#ratelimit_limitObject

Requests are limited to API v3 to 5000 per hour.



31
32
33
# File 'lib/github_api2/response/header.rb', line 31

def ratelimit_limit
  loaded? ? env[:response_headers][RATELIMIT_LIMIT] : nil
end

#ratelimit_remainingObject



35
36
37
# File 'lib/github_api2/response/header.rb', line 35

def ratelimit_remaining
  loaded? ? env[:response_headers][RATELIMIT_REMAINING] : nil
end

#ratelimit_resetObject

A unix timestamp describing when the ratelimit will be reset



41
42
43
# File 'lib/github_api2/response/header.rb', line 41

def ratelimit_reset
  loaded? ? env[:response_headers][RATELIMIT_RESET] : nil
end

#serverObject



69
70
71
# File 'lib/github_api2/response/header.rb', line 69

def server
  loaded? ? env[:response_headers][SERVER] : nil
end

#statusObject



73
74
75
# File 'lib/github_api2/response/header.rb', line 73

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

#success?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/github_api2/response/header.rb', line 77

def success?
  SUCCESSFUL_STATUSES.include? status
end