Class: TheCity::GroupCheckinEventsList

Inherits:
ApiList
  • Object
show all
Includes:
Enumerable
Defined in:
lib/api/group_checkin_events_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 = {}) ⇒ GroupCheckinEventsList

Constructor.

Options:

:group_id - The ID of the group to load the checkin events for. (required)
:page - The page number to get.
:target_date - Date to pull checkin events for. Defaults to nearest checkin date
:reader - The Reader to use to load the data.

Examples:

GroupCheckinEventsList.new({:group_id => 12345})

GroupCheckinEventsList.new({:group_id => 12345, :page => 2})

Parameters:

  • options (defaults to: {})

    A hash of options for loading the list.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/api/group_checkin_events_list.rb', line 23

def initialize(options = {})
  @options = options
  @options[:reader] = TheCity::GroupCheckinEventsListReader.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']
  @target_date = @json_data['target_date']
end

Instance Method Details

#[](index) ⇒ GroupCheckinEvent

Get the specified note.

Parameters:

  • index

    The index of the checkin event to get.

Returns:



41
42
43
# File 'lib/api/group_checkin_events_list.rb', line 41

def [](index)
  GroupCheckinEvent.new( @json_data['checkin_events'][index] ) if @json_data['checkin_events'][index]
end

#each(&block) ⇒ Object

This method is needed for Enumerable.



47
48
49
# File 'lib/api/group_checkin_events_list.rb', line 47

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

#empty?Boolean

Checks if the list is empty.

Returns:

  • (Boolean)

    True on empty, false otherwise.



58
59
60
# File 'lib/api/group_checkin_events_list.rb', line 58

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