5 attr_accessor :query, :sort_by, :index_start, :index_end, :records
7 #All values of initialize are optional, though you'll want to supply it with a query object if you intend on getting records into your set through a z39.50 search. index_start and index_end will be used for the TUI display.
8 def initialize(query_object=nil, sort_by='title', index_start=0, index_end=5 )
9 @query = query_object #query object
12 @index_start = index_start
13 @index_end = index_end
15 #puts self.index_start
17 #puts self.records.class
21 #Pretty prints the result set object. Nests pretty printed record objects within.
23 full_string = "-------RESULT SET--------------\n" + "Result set has #{self.records.size} records."
24 self.records.each do |record|
25 full_string << record.to_s
27 full_string += "-------RESULT SET--------------\n"
30 # Method to add records only to a result set.
32 self.records << record
35 # appends a result set to another.
36 # Replaces the query and sort_by instance variables with the new ones.
39 self.records << result_set.records
40 self.query = result_set.query
41 self.sort_by = result_set.sort_by
43 #puts self.records.inspect
46 #Removes unselected records from the result set. Uses the selected instance variable to check for true or false.
47 def remove_unselected!
48 self.records.each_index do |i|
49 if self.records[i].nil?
51 self.records[i] = nil unless self.records[i].selected
59 #Number of records in the result set
67 selected_records = self.find_all{|record| record.selected unless record == nil}
68 selected_records.length
69 end #returns number of ZCC::Records with @selected set to true
71 alias selected_length selected_size
76 for record in @records
85 end #=> hash{zurl=>[rec, rec],zurl=>[rec, rec]
88 end # Record at that position
91 if self.records.size == 0
93 elsif self.records.size > 0
96 end #returns true if the @ZCCRecords array is empty or only nil values
99 #self.find_all {|record| record.selected}