Sha256: 717191f80065c6e8af0f0f4597d5e327808640ab94787b8df77d12e8148af2a0
Contents?: true
Size: 1.36 KB
Versions: 11
Compression:
Stored size: 1.36 KB
Contents
module TheCity class CheckinList < ApiList include Enumerable # Constructor. # # @param options A hash of options for loading the list. # # Options: # :page - The page number to get. # :reader - The Reader to use to load the data. # # # Examples: # CheckinList.new # # CheckinList.new({:page => 2}) # def initialize(options = {}) @options = options @options[:reader] = TheCity::CheckinListReader.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 # Get the specified note. # # @param index The index of the checkin to get. # # @return [Checkin] def [](index) Checkin.new( @json_data['checkins'][index] ) if @json_data['checkins'][index] end # This method is needed for Enumerable. def each &block @json_data['checkins'].each{ |checkin| yield( Checkin.new(checkin) )} end # Alias the count method alias :size :count # Checks if the list is empty. # # @return True on empty, false otherwise. def empty? @json_data['checkins'].empty? end end end
Version data entries
11 entries across 11 versions & 1 rubygems