Sha256: 5e50857fc36459da4b62f02ac8f2671f4bbcbb22e7619301dda34dd004729567

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module ShelbyArena

  class FundList

    include Enumerable

    # attr_reader :count, :page_number, :total_records, :additional_pages


    # 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::FundListReader.new(options)    
      @json_data = reader.load_data['FundListResult']['Funds']['Fund']
    end

    # Get the specified fund.
    #
    # @param index The index of the fund to get.
    #
    # @return Fund
    def [](index)
      Fund.new( @json_data[index] ) unless @json_data[index].nil?
    end


    # This method is needed for Enumerable.
    def each &block
      @json_data.each{ |fund| yield( Fund.new(fund) )}
    end

    # Alias the count method
    alias :size :count


    # Checks if the list is empty.
    #
    # @return True on empty, false otherwise.
    def empty?
      self.count == 0 ? true : false
    end

  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shelby-arena-api-0.1.0 lib/api/fund_list.rb