Class: Hip3::Item

Inherits:
Holding show all
Defined in:
app/models/hip3/item.rb

Overview

Item objects need to be initialized with reXML object representing the item element.

Constant Summary collapse

@@Field_labels =

Labels set up in HIP admin item display to expose these data of interest.

{ :rmst => 'hide_rmst', :barcode => 'hide_barcode', :copy_id => 'hide_CopyNum'}

Instance Attribute Summary collapse

Attributes inherited from Holding

#bib, #call_no, #collection_str, #copy_str, #coverage_str, #id, #location_str, #notes, #status_str

Instance Method Summary collapse

Methods inherited from Holding

#coverage_str_to_a, #dummy?, #textValue

Constructor Details

#initialize(item_row_element, arg_bib) ⇒ Item

Item is not lazily loadable–you need to give it all three arguments to create it, you need to have the XML in hand. We could certainly provide a different way than XML to init values, but we haven’t.



18
19
20
21
# File 'app/models/hip3/item.rb', line 18

def initialize(item_row_element, arg_bib)
	@bib = arg_bib
	loadFromItemRowElement(item_row_element)
end

Instance Attribute Details

#avail_date_strObject

Item-specific attributes



11
12
13
# File 'app/models/hip3/item.rb', line 11

def avail_date_str
  @avail_date_str
end

#barcodeObject

Item-specific attributes



11
12
13
# File 'app/models/hip3/item.rb', line 11

def barcode
  @barcode
end

#copyObject

Returns the value of attribute copy.



12
13
14
# File 'app/models/hip3/item.rb', line 12

def copy
  @copy
end

#copy_idObject

Item-specific attributes



11
12
13
# File 'app/models/hip3/item.rb', line 11

def copy_id
  @copy_id
end

#rmst_strObject

Item-specific attributes



11
12
13
# File 'app/models/hip3/item.rb', line 11

def rmst_str
  @rmst_str
end

Instance Method Details

#hasSerialCopyObject



59
60
61
# File 'app/models/hip3/item.rb', line 59

def hasSerialCopy
	return ! self.copy.nil?
end

#loadFromItemRowElement(el) ⇒ Object



23
24
25
26
27
28
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
57
# File 'app/models/hip3/item.rb', line 23

def loadFromItemRowElement( el )
    
	@id = textValue(el.at('/key'));			
	
	# Pull out the values built into HIP automatically. They have weird
	# XML elements, but I think I've appropriately identified them, 
	# even though it doesn't look like it.Actually, no, those aren't
    # reliable, I don't understand what they are. We'll just pull
    # everything from the HIP display.
    
	#@copy_str = textValue(el.elements['MIDSPINE/data/text'])
    @copy_str = @bib.item_field_lookup.text_value_for(el, "Copy")
    @collection_str = @bib.item_field_lookup.text_value_for(el, "Collection")

    #Maybe. Not sure where else to get this. 
	@location_str = textValue(el.at('/LOCALLOCATION/data/text'))
    
	#@call_no = textValue(el.elements['COPYNUMBER/data/text'])
    @call_no = @bib.item_field_lookup.text_value_for(el, "Call No.")
    			
    @status_str = @bib.item_field_lookup.text_value_for(el, "Status")

    # Not sure about this one. 
	@avail_date_str = textValue(el.at('/AVAILABILITYDATE/data/text'))
	
	# Pull out the values we had to configure in Copy display
	@rmst_str = @bib.item_field_lookup.text_value_for(el, @@Field_labels[:rmst])
	@barcode = @bib.item_field_lookup.text_value_for(el, @@Field_labels[:barcode])
	@copy_id = @bib.item_field_lookup.text_value_for(el, @@Field_labels[:copy_id])
	
	# Attach this thing to the proper Copy object, in both directions. 
	# We have the Bib do it for us, since the Bib has a list of Copies.
	# Since we've set our @copy_id, the Bib can find out what it needs to.
	@bib.register_item( self)			
end