Class: TheCity::CheckinList

Inherits:
ApiList
  • Object
show all
Includes:
Enumerable
Defined in:
lib/api/checkin_list.rb

Instance Attribute Summary

Attributes inherited from ApiList

#current_page, #per_page, #total_entries, #total_pages

Instance Method Summary collapse

Methods inherited from ApiList

load, #next_page, #next_page!, #next_page?

Constructor Details

#initialize(options = {}) ⇒ CheckinList

Constructor.

Options:

:page - The page number to get.
:reader - The Reader to use to load the data.

Examples:

CheckinList.new

CheckinList.new({:page => 2})

Parameters:

  • options (defaults to: {})

    A hash of options for loading the list.



21
22
23
24
25
26
27
28
29
30
# File 'lib/api/checkin_list.rb', line 21

def initialize(options = {}) 
  @options = options
  @options[:reader] = TheCity::CheckinListReader.new(@options) if @options[:reader].nil?
  @json_data = @options[:reader].load_feed 

  @total_entries = @json_data['total_entries']
  @total_pages = @json_data['total_pages']
  @per_page = @json_data['per_page']
  @current_page = @json_data['current_page']      
end

Instance Method Details

#[](index) ⇒ Checkin

Get the specified note.

Parameters:

  • index

    The index of the checkin to get.

Returns:



37
38
39
# File 'lib/api/checkin_list.rb', line 37

def [](index)
  Checkin.new( @json_data['checkins'][index] ) if @json_data['checkins'][index]
end

#each(&block) ⇒ Object

This method is needed for Enumerable.



43
44
45
# File 'lib/api/checkin_list.rb', line 43

def each &block
  @json_data['checkins'].each{ |checkin| yield( Checkin.new(checkin) )}
end

#empty?Boolean

Checks if the list is empty.

Returns:

  • (Boolean)

    True on empty, false otherwise.



54
55
56
# File 'lib/api/checkin_list.rb', line 54

def empty?
  @json_data['checkins'].empty?
end