Class: Hip3::Item

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

Overview

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

Constant Summary

@@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

#identifier, #locations

Instance Method Summary (collapse)

Methods inherited from Holding

#find_item_by_attribute, #find_location

Constructor Details

- (Item) initialize(item_row_element, arg_bib)

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 'lib/hip3/item.rb', line 18

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

Instance Attribute Details

- (Object) avail_date_str

Item-specific attributes



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

def avail_date_str
  @avail_date_str
end

- (Object) barcode

Item-specific attributes



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

def barcode
  @barcode
end

- (Object) copy

Returns the value of attribute copy



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

def copy
  @copy
end

- (Object) copy_id

Item-specific attributes



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

def copy_id
  @copy_id
end

- (Object) rmst_str

Item-specific attributes



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

def rmst_str
  @rmst_str
end

Instance Method Details

- (Object) hasSerialCopy



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

def hasSerialCopy
	return ! self.copy.nil?
end

- (Object) loadFromItemRowElement(el)



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 'lib/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