From 16e0e5969dceabe81596c03ac56230943c7f70a3 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 16 Jul 2007 17:34:42 +0000 Subject: [PATCH] starting to move the result set into the cli_display. will have to refactor some of the menu code to handle an array of ZCC::Records instead of an array of MARC::Records git-svn-id: svn+ssh://rubyforge.org/var/svn/zcc/trunk@208 695555e7-a3f4-42c9-822d-1d0ed3746087 --- bin/zcc-new | 5 +++-- lib/zcc/cli_display.rb | 21 ++++++++++++++------- specs/classes.rb | 7 +------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/bin/zcc-new b/bin/zcc-new index 9966447..09e9469 100644 --- a/bin/zcc-new +++ b/bin/zcc-new @@ -99,10 +99,11 @@ query = Query.new(search_term, zserver_objects[0]) results = query.search(5) #print "results.class: " #puts results.class -puts results.to_s +#puts results.to_s +taken = zcc_select_good_marc(results, 'one') # # - exit + #SCRIPTING and EDITING if SCRIPTING print $clear_code diff --git a/lib/zcc/cli_display.rb b/lib/zcc/cli_display.rb index bec9e07..8b9d72e 100755 --- a/lib/zcc/cli_display.rb +++ b/lib/zcc/cli_display.rb @@ -1,13 +1,17 @@ module ZCC - def zcc_select_good_marc(taken, take_how_many) + def zcc_select_good_marc(results, take_how_many) #puts self[0] - unless taken[0].is_a? MARC::Record - raise ArgumentError, "This Array doesn't have a MARC::Record!" - end + #unless taken[0].is_a? MARC::Record + # raise ArgumentError, "This Array doesn't have a MARC::Record!" + #end #puts self - rec_copy = taken.dup - rec_copy = rec_copy.sort_by {|rec| rec['245']['a']} + + rec_copy = results.records + puts rec_copy.class + puts rec_copy.inspect + STDIN.gets + #rec_copy = rec_copy.sort_by {|rec| rec['245']['a']} clear = %x{clear} #print clear @@ -182,10 +186,13 @@ module ZCC end def display_menu(rec_copy, index) + puts rec_copy.class + puts rec_copy[index].class + STDIN.gets field_width = $term_width - 8 say("<%= color(\"#{index}\", :index) %> ") ['245', '260', '300'].each do |field| - string = rec_copy[index][field].to_s + string = rec_copy[index].marc[field].to_s string.rstrip! string.lstrip! if string.length < field_width diff --git a/specs/classes.rb b/specs/classes.rb index 6eb9906..ea46e57 100644 --- a/specs/classes.rb +++ b/specs/classes.rb @@ -9,12 +9,7 @@ module ZCC - class Record (@zurl, @selected = false) - @zurl #zurl, which can be a key to zserver record - @zserver - @selected #is this record true or false (default - def to_s; puts @s; end - end + class MARC21 < Record @marc #MARC::Record obj -- 2.11.4.GIT