Class: Hip3::SerialCopy
- Defined in:
- app/models/hip3/serial_copy.rb
Overview
data, and the bib loads it at once for all copies, in one fetch.
Constant Summary collapse
- @@Field_labels =
{:location => 'Location', :collection => 'Collection', :call_no => 'Call No.', :copy_str => 'Copy No.', :status => 'Status', :notes => 'Notes'}
Instance Attribute Summary collapse
-
#items ⇒ Object
array of items.
-
#items_loaded ⇒ Object
Returns the value of attribute items_loaded.
-
#runs ⇒ Object
array of run types/statements.
Attributes inherited from Holding
#bib, #call_no, #collection_str, #copy_str, #id, #location_str, #notes, #status_str
Instance Method Summary collapse
-
#coverage_str ⇒ Object
Not too useful, use coverage_str_to_a instead usually.
-
#coverage_str_to_a ⇒ Object
Over-riding.
-
#initialize(argBibObj, serialXmlElement = nil) ⇒ SerialCopy
constructor
A new instance of SerialCopy.
- #items_loaded? ⇒ Boolean
- #loadFromSerialElement(serialElement) ⇒ Object
- #register_item(item) ⇒ Object
Methods inherited from Holding
Constructor Details
#initialize(argBibObj, serialXmlElement = nil) ⇒ SerialCopy
Returns a new instance of SerialCopy.
11 12 13 14 15 16 17 |
# File 'app/models/hip3/serial_copy.rb', line 11 def initialize(argBibObj, serialXmlElement=nil) self.bib = argBibObj self.items_loaded = false if ( serialXmlElement ) loadFromSerialElement( serialXmlElement ) end end |
Instance Attribute Details
#items ⇒ Object
array of items
7 8 9 |
# File 'app/models/hip3/serial_copy.rb', line 7 def items @items end |
#items_loaded ⇒ Object
Returns the value of attribute items_loaded.
8 9 10 |
# File 'app/models/hip3/serial_copy.rb', line 8 def items_loaded @items_loaded end |
#runs ⇒ Object
array of run types/statements
9 10 11 |
# File 'app/models/hip3/serial_copy.rb', line 9 def runs @runs end |
Instance Method Details
#coverage_str ⇒ Object
Not too useful, use coverage_str_to_a instead usually
59 60 61 |
# File 'app/models/hip3/serial_copy.rb', line 59 def coverage_str return runs.to_s end |
#coverage_str_to_a ⇒ Object
Over-riding
64 65 66 67 68 69 70 71 72 |
# File 'app/models/hip3/serial_copy.rb', line 64 def coverage_str_to_a runs.collect do |r| s = '' (s << r[:label] << ": ") if (! r[:label].blank?) && r[:label] != "Main run" s << r[:statement] s << '-- ' << r[:note] if r[:note] s end end |
#items_loaded? ⇒ Boolean
25 26 27 |
# File 'app/models/hip3/serial_copy.rb', line 25 def items_loaded? return (items_loaded == true) end |
#loadFromSerialElement(serialElement) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/hip3/serial_copy.rb', line 29 def loadFromSerialElement( serialElement ) self.location_str = serialElement.at('/location').inner_text self.id = serialElement.at('/copykey').inner_text # Okay, this part is potentially fragile, we have to pull out based on # order in the XML, not sure if that can change. Sorry, that's HIP for you. copyElements = serialElement.search('/copy/cell/data/text').collect {|e| e.inner_text} # Fix this to use field lookup self.location_str = bib.copy_field_lookup.text_value_for(copyElements, @@Field_labels[:location]) self.collection_str = bib.copy_field_lookup.text_value_for(copyElements, @@Field_labels[:collection]) self.call_no = bib.copy_field_lookup.text_value_for(copyElements, @@Field_labels[:call_no]) self.copy_str = bib.copy_field_lookup.text_value_for(copyElements, @@Field_labels[:copy_str]) self.status_str = bib.copy_field_lookup.text_value_for(copyElements, @@Field_labels[:status]) self.notes = bib.copy_field_lookup.text_value_for(copyElements, @@Field_labels[:notes]) #Okay, got to get the 'runs' for summary holdings info. self.runs ||= [] serialElement.search('/runlist/run').each do |run| label = run.at('/runlabel').inner_text run.search('/data/rundata').each do |rundata| run = {:label => label, :statement => textValue(rundata.at('/text'))} run[:note] = textValue(rundata.at('/note')) self.runs.push( run ) end end end |
#register_item(item) ⇒ Object
74 75 76 77 78 79 80 |
# File 'app/models/hip3/serial_copy.rb', line 74 def register_item(item) items ||= [] unless items.include?(item) items.push(item) end end |