module Pickers def select_good_marc(take_how_many) #puts self[0] unless self[0].is_a? MARC::Record raise ArgumentError, "This Array doesn't have a MARC::Record!" end #puts self rec_copy = self.dup #print "rec_copy.length: ", rec_copy.length #print "rec_copy.class: ", rec_copy.class #puts rec_copy[3] #if it chokes on a record uncomment and include the record number #i = 0 recs_to_return = [] loop { rec_copy.each_index do #This block lists |index| puts "#{index}\t#{rec_copy[index]['245']}" puts "\t#{rec_copy[index]['300']}" if rec_copy[index]['300'] puts "\n\n" end if take_how_many =='one' print "\nEnter # | s# | c#-# | l# | none : " else print "\nEnter # | n | s# | c#-# | l# | d : " end whichrec = STDIN.gets.chomp! #puts "whichrec #{whichrec[0,1]}" #puts whichrec.class #whichrec = whichrec.to_i unless whichrec.respond_to?(:upcase) first_bit = whichrec[0,1] puts "whichrec is an Integer" if whichrec.is_a?(Integer) see_num = whichrec[1,9].to_i if first_bit == 's' puts rec_copy[see_num] print "\n\nHit enter to continue." STDIN.gets.chomp next elsif first_bit == 'c' puts "comparison time!" comparison = whichrec[1,99] compare_nums = comparison.split('-') rec_copy[compare_nums[0].to_i].compare_marc(rec_copy[compare_nums[1].to_i]) puts "\nHit enter to continue." STDIN.gets next elsif first_bit == 'l' #puts rec_copy[whichrec[1,99].to_i] #gets rec_copy[whichrec[1,99].to_i].linter puts "\nHit enter to continue." STDIN.gets next elsif take_how_many == 'one' if ( whichrec == 'none' ) puts "Since you cannot decide on a good record, please refer the book to a cataloger." return "none" elsif ( first_bit =~ /[a-z]/i or whichrec == '' ) puts "that's not a valid value. try again." next else if whichrec.to_i > (rec_copy.length - 1) puts "Your number exceeds the number of records in your retrieved set." next else return recs_to_return << rec_copy[whichrec.to_i] end end elsif take_how_many == 'multi' if whichrec == 'd' puts "You will not search any more zservers!" recs_to_return << "done" elsif ( whichrec == 'n' or whichrec == '' ) puts "recs that will be returned #{recs_to_return.length}" return recs_to_return elsif whichrec[0,1] =~ /[a-z]/i puts "that's not a valid value. try again." next else if whichrec.to_i > (rec_copy.length - 1) puts "Your number exceeds the number of records in your retrieved set." next else #puts "adding record to recs_to_return" recs_to_return << rec_copy[whichrec.to_i] #puts "recs_to_return.length #{recs_to_return.length}" next end end else puts "That's not a valid value take_how_many value to pass into select_good_marc!" end #puts "group whichrec.to_i #{whichrec.to_i}" return recs_to_return } end end