module BitBucket::Result
Public Instance Methods
Returns raw body
# File lib/bitbucket_rest_api/result.rb, line 53 def body loaded? ? @env[:body] : nil end
# File lib/bitbucket_rest_api/result.rb, line 16 def cache_control loaded? ? @env[:response_headers][CACHE_CONTROL] : nil end
# File lib/bitbucket_rest_api/result.rb, line 24 def content_length loaded? ? @env[:response_headers][CONTENT_LENGTH] : nil end
# File lib/bitbucket_rest_api/result.rb, line 20 def content_type loaded? ? @env[:response_headers][CONTENT_TYPE] : nil end
# File lib/bitbucket_rest_api/result.rb, line 32 def date loaded? ? @env[:response_headers][DATE] : nil end
Iterator like each for response pages. If there are no pages to iterate over this method will return nothing.
# File lib/bitbucket_rest_api/result.rb, line 68 def each_page yield body yield next_page while page_iterator.has_next? end
# File lib/bitbucket_rest_api/result.rb, line 28 def etag loaded? ? @env[:response_headers][ETAG] : nil end
Retrives the result of the first page. Returns nil
if there is no first page - either because you are already on the first page or there are no pages at all in the result.
# File lib/bitbucket_rest_api/result.rb, line 76 def first_page first_request = page_iterator.first instance_eval { @env = first_request.env } if first_request body end
Returns true
if there is another page in the result set, otherwise false
# File lib/bitbucket_rest_api/result.rb, line 120 def has_next_page? page_iterator.has_next? end
Retrives the result of the last page. Returns nil
if there is no last page - either because you are already on the last page, there is only one page or there are no pages at all in the result.
# File lib/bitbucket_rest_api/result.rb, line 102 def last_page last_request = page_iterator.last instance_eval { @env = last_request.env } if last_request body end
Return page links
# File lib/bitbucket_rest_api/result.rb, line 62 def links @@links = BitBucket::PageLinks.new(@env[:response_headers]) end
# File lib/bitbucket_rest_api/result.rb, line 57 def loaded? !!@env end
# File lib/bitbucket_rest_api/result.rb, line 36 def location loaded? ? @env[:response_headers][LOCATION] : nil end
Retrives the result of the next page. Returns nil
if there is no next page or no pages at all.
# File lib/bitbucket_rest_api/result.rb, line 84 def next_page next_request = page_iterator.next instance_eval { @env = next_request.env } if next_request body end
Retrives a specific result for a page given page number. The page_number
parameter is not validate, hitting a page that does not exist will return BitBucket
API
error. Consequently, if there is only one page, this method returns nil
# File lib/bitbucket_rest_api/result.rb, line 112 def page(page_number) request = page_iterator.get_page(page_number) instance_eval { @env = request.env } if request body end
Retrives the result of the previous page. Returns nil
if there is no previous page or no pages at all.
# File lib/bitbucket_rest_api/result.rb, line 92 def prev_page prev_request = page_iterator.prev instance_eval { @env = prev_request.env } if prev_request body end
TODO: Add result counts method to check total items looking at result links
# File lib/bitbucket_rest_api/result.rb, line 8 def ratelimit_limit loaded? ? @env[:response_headers][RATELIMIT_LIMIT] : nil end
# File lib/bitbucket_rest_api/result.rb, line 12 def ratelimit_remaining loaded? ? @env[:response_headers][RATELIMIT_REMAINING] : nil end
Repopulates objects for new values
# File lib/bitbucket_rest_api/result.rb, line 125 def reset nil end
# File lib/bitbucket_rest_api/result.rb, line 40 def server loaded? ? @env[:response_headers][SERVER] : nil end
# File lib/bitbucket_rest_api/result.rb, line 44 def status loaded? ? @env[:status] : nil end
# File lib/bitbucket_rest_api/result.rb, line 48 def success? (200..299).include? status end