Sha256: 36cc6ea67cc945c47c236ac46365ff2736cf14e1c45bd341259ac8f9bcd31770
Contents?: true
Size: 1.67 KB
Versions: 12
Compression:
Stored size: 1.67 KB
Contents
module TheCity class UserProcessAnswerList < ApiList include Enumerable # Constructor. # # @param options A hash of options for loading the list. # # Options: # :user_id - The ID of the user to load the answers for the process. (required) # :process_id - The ID of the user's process to load the answers for. (required) # :page - The page number to get. # :reader - The Reader to use to load the data. # # # Examples: # UserProcessAnswerList.new({:user_id => 12345, :process_id => 23456}) # # UserProcessAnswerList.new({:user_id => 12345, :process_id => 23456, :page => 2}) # def initialize(options = {}) @options = options @options[:page] ||= 1 @options[:reader] = TheCity::UserProcessAnswerListReader.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 processes. # # @param index The index of the process to get. # # @return [UserProcesses] def [](index) UserProcessAnswer.new( @json_data['answers'][index] ) if @json_data['answers'][index] end # This method is needed for Enumerable. def each &block @json_data['answers'].each{ |process| yield( UserProcessAnswer.new(process) )} end # Alias the count method alias :size :count # Checks if the list is empty. # # @return True on empty, false otherwise. def empty? @json_data['answers'].empty? end end end
Version data entries
12 entries across 12 versions & 1 rubygems