Sha256: 07dc13443eb04f1521b5442a101a37e9a51a44009aa7f215f3b113edb335005f
Contents?: true
Size: 1.37 KB
Versions: 14
Compression:
Stored size: 1.37 KB
Contents
module TheCity class CheckinList include Enumerable attr_reader :total_entries, :total_pages, :per_page, :current_page # 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 = {}) reader = options[:reader] || TheCity::CheckinListReader.new(options) @json_data = 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
14 entries across 14 versions & 1 rubygems