class Twitter::Cursor

Attributes

attrs[R]

@return [Hash]

to_h[R]

@return [Hash]

to_hash[R]

@return [Hash]

Public Class Methods

new(key, klass, request) click to toggle source

Initializes a new Cursor

@param key [String, Symbol] The key to fetch the data from the response @param klass [Class] The class to instantiate objects in the response @param request [Twitter::REST::Request] @return [Twitter::Cursor]

# File lib/twitter/cursor.rb, line 21
def initialize(key, klass, request)
  @key = key.to_sym
  @klass = klass
  @client = request.client
  @request_method = request.verb
  @path = request.path
  @options = request.options
  @collection = []
  self.attrs = request.perform
end

Private Instance Methods

attrs=(attrs) click to toggle source

@param attrs [Hash] @return [Hash]

# File lib/twitter/cursor.rb, line 53
def attrs=(attrs)
  @attrs = attrs
  @attrs.fetch(@key, []).each do |element|
    @collection << (@klass ? @klass.new(element) : element)
  end
  @attrs
end
fetch_next_page() click to toggle source

@return [Hash]

# File lib/twitter/cursor.rb, line 46
def fetch_next_page
  response = Twitter::REST::Request.new(@client, @request_method, @path, @options.merge(:cursor => next_cursor)).perform
  self.attrs = response
end
last?() click to toggle source

@return [Boolean]

# File lib/twitter/cursor.rb, line 41
def last?
  next_cursor.zero?
end
next()
Alias for: next_cursor
next_cursor() click to toggle source

@return [Integer]

# File lib/twitter/cursor.rb, line 35
def next_cursor
  @attrs[:next_cursor] || -1
end
Also aliased as: next