Class: ShelbyArena::PersonList

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PersonList

Constructor.

Options: :reader - (optional) The Reader to use to load the data.



13
14
15
16
# File 'lib/api/person_list.rb', line 13

def initialize(options = {})
  reader = options[:reader] || ShelbyArena::PersonListReader.new(options)
  @json_data = reader.load_data['PersonListResult']['Persons']['Person']
end

Instance Method Details

#[](index) ⇒ Person

Get the specified person.



23
24
25
# File 'lib/api/person_list.rb', line 23

def [](index)
  Person.new( @json_data[index] ) unless @json_data[index].nil?
end

#each(&block) ⇒ Object

This method is needed for Enumerable.



29
30
31
# File 'lib/api/person_list.rb', line 29

def each &block
  @json_data.each{ |person| yield( Person.new(person) )}
end

#empty?Boolean

Checks if the list is empty.



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

def empty?
  #@json_data['person'].empty?
  self.count == 0 ? true : false
end

#raw_dataObject

Access to the raw JSON data. This method is needed for merging lists.



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

def raw_data
  @json_data
end