Sha256: e2bcb55c2e880c2e22180c2f349437a08ae11279826ff652d1ad4e11b92880cc
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
module ShelbyArena class PersonList include Enumerable # Constructor. # # @param options A hash of options for loading the list. # # Options: # :reader - (optional) The Reader to use to load the data. def initialize(options = {}) reader = options[:reader] || ShelbyArena::PersonListReader.new(options) @json_data = reader.load_data['PersonListResult']['Persons']['Person'] end # Get the specified person. # # @param index The index of the person to get. # # @return [Person] def [](index) Person.new( @json_data[index] ) unless @json_data[index].nil? end # This method is needed for Enumerable. def each &block @json_data.each{ |person| yield( Person.new(person) )} end # Alias the count method alias :size :count # Checks if the list is empty. # # @return True on empty, false otherwise. def empty? #@json_data['person'].empty? self.count == 0 ? true : false end # Access to the raw JSON data. This method is needed for merging lists. # # @returns Raw JSON data. def raw_data @json_data end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shelby-arena-api-0.1.0 | lib/api/person_list.rb |