Class: TheCity::GroupEventAttendanceList

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

Constructor.

Options:

:group_id - The ID of the group to load the addresses for. (required)
:page - The page number to get.
:reader - The Reader to use to load the data.

Examples:

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

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

Parameters:

  • options (defaults to: {})

    A hash of options for loading the list.



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

def initialize(options = {}) 
  @options = options
  @options[:reader] = TheCity::GroupEventAttendanceListReader.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) ⇒ GroupEventAttendance

Get the specified note.

Parameters:

  • index

    The index of the note to get.

Returns:



39
40
41
# File 'lib/api/group_event_attendance_list.rb', line 39

def [](index)
  GroupEventAttendance.new( @json_data['event_attendances'][index] ) if @json_data['event_attendances'][index]
end

#each(&block) ⇒ Object

This method is needed for Enumerable.



45
46
47
# File 'lib/api/group_event_attendance_list.rb', line 45

def each &block
  @json_data['event_attendances'].each{ |attendance| yield( GroupEventAttendance.new(attendance) )}
end

#empty?Boolean

Checks if the list is empty.

Returns:

  • (Boolean)

    True on empty, false otherwise.



56
57
58
# File 'lib/api/group_event_attendance_list.rb', line 56

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