Class: Twitter::Cursor

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter/cursor.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], lazy_attr_reader

Constructor Details

#initialize(attrs, method, klass = nil) ⇒ Twitter::Cursor

Initializes a new Cursor object

Parameters:



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/twitter/cursor.rb', line 17

def initialize(attrs, method, klass=nil)
  super(attrs)
  @collection = Array(attrs[method.to_s]).map do |item|
    if klass
      klass.new(item)
    else
      item
    end
  end
  singleton_class.class_eval do
    alias_method method.to_sym, :collection
  end
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



6
7
8
# File 'lib/twitter/cursor.rb', line 6

def collection
  @collection
end

Instance Method Details

#first?Boolean Also known as: first

Returns:

  • (Boolean)


32
33
34
# File 'lib/twitter/cursor.rb', line 32

def first?
  previous_cursor.zero?
end

#last?Boolean Also known as: last

Returns:

  • (Boolean)


38
39
40
# File 'lib/twitter/cursor.rb', line 38

def last?
  next_cursor.zero?
end