Class: ShelbyArena::ContributionList

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ContributionList

Constructor.

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

Parameters:

  • options (defaults to: {})

    A hash of options for loading the list.



16
17
18
19
# File 'lib/api/contribution_list.rb', line 16

def initialize(options = {})
  reader = options[:reader] || ShelbyArena::ContributionListReader.new(options)    
  @json_data = reader.load_data['ContributionListResult']['Contributions']['Contribution']
end

Instance Method Details

#[](index) ⇒ Object

Get the specified contribution.

Parameters:

  • index

    The index of the contribution to get.

Returns:

  • Contribution



26
27
28
# File 'lib/api/contribution_list.rb', line 26

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

#each(&block) ⇒ Object

This method is needed for Enumerable.



32
33
34
# File 'lib/api/contribution_list.rb', line 32

def each &block
  @json_data.each{ |contribution| yield( Contribution.new(contribution) )}
end

#empty?Boolean

Checks if the list is empty.

Returns:

  • (Boolean)

    True on empty, false otherwise.



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

def empty?
  self.count == 0 ? true : false
end