Class Exlibris::Primo::Holding
In: lib/exlibris/primo/holding.rb
Parent: Object

Class for handling Primo Holdings from display/availlibrary TODO: Should probably extend a base class of some sort

Methods

Attributes

call_number  [RW] 
collection_str  [R] 
coverage_str  [R] 
id_one  [RW] 
id_two  [RW] 
institution  [RW] 
library  [R] 
library_code  [RW] 
notes  [R] 
origin  [RW] 
original_source_id  [RW] 
primo_base_url  [RW] 
primo_config  [RW] 
primo_url  [R] 
primo_view_id  [RW] 
raw  [RW] 
record_id  [RW] 
request_url  [R] 
source_config  [RW] 
source_id  [RW] 
source_record_id  [RW] 
status  [RW] 
status_code  [RW] 
text  [RW] 
type  [RW] 
url  [R] 

Public Class methods

[Source]

    # File lib/exlibris/primo/holding.rb, line 14
14:     def initialize(e)
15:       unless e.nil?
16:         if e.kind_of? Holding
17:           @primo_config = e.primo_config
18:           @raw = e.raw
19:           @text = e.text
20:           @institution = e.institution
21:           @library_code = e.library_code
22:           @id_one = e.id_one
23:           @id_two = e.id_two
24:           @status_code = e.status_code
25:           @origin = e.origin
26:           @collection_str = e.collection_str
27:           @call_number = e.call_number
28:           @record_id = e.record_id
29:           @primo_base_url = e.primo_base_url
30:           @primo_view_id = e.primo_view_id
31:           @record_id = e.record_id
32:           @original_source_id = e.original_source_id
33:           @source_id = e.source_id
34:           @source_record_id = e.source_record_id
35:           @type = e.type
36:           @source_config = e.source_config
37:         elsif e.kind_of? Hpricot::Elem
38:           @primo_config = primo_config
39:           @raw = e 
40:           @text = raw.inner_text
41:           a = text.split(/\$(?=\$)/) unless raw.nil?
42:           a.each do |s|
43:             @institution = s.sub!(/^\$I/, "") unless s.match(/^\$I/).nil?
44:             @library_code = s.sub!(/^\$L/, "") unless s.match(/^\$L/).nil?
45:             @id_one = s.sub!(/^\$1/, "") unless s.match(/^\$1/).nil?
46:             @id_two = s.sub!(/^\$2/, "") unless s.match(/^\$2/).nil?
47:             @status_code = s.sub!(/^\$S/, "") unless s.match(/^\$S/).nil?
48:             @origin = s.sub!(/^\$O/, "") unless s.match(/^\$O/).nil?
49:           end
50:           @call_number = id_two
51:         end
52:       end
53:     end

Public Instance methods

[Source]

    # File lib/exlibris/primo/holding.rb, line 73
73:     def collection_str
74:       library# + id_one
75:     end

[Source]

    # File lib/exlibris/primo/holding.rb, line 81
81:     def coverage_str
82:     end

Return an array of holding strings, possibly empty, possibly single-valued. over-ridden by SerialCopy to give you an array, since SerialCopies have multiple holdings strings.

[Source]

    # File lib/exlibris/primo/holding.rb, line 87
87:     def coverage_str_to_a
88:       return coverage_str.nil? ? [] : [coverage_str]
89:     end

[Source]

    # File lib/exlibris/primo/holding.rb, line 60
60:     def library
61:       h = primo_config["libraries"] unless primo_config.nil?
62:       map(library_code, h)
63:     end

[Source]

    # File lib/exlibris/primo/holding.rb, line 91
91:     def notes
92:     end

[Source]

    # File lib/exlibris/primo/holding.rb, line 55
55:     def primo_url
56:       return if primo_base_url.nil? or primo_view_id.nil? or record_id.nil?
57:       return primo_base_url + "/primo_library/libweb/action/dlDisplay.do?docId=" + record_id + "&institution=" + institution + "&vid=" + primo_view_id + "&reset_config=true"
58:     end

[Source]

    # File lib/exlibris/primo/holding.rb, line 65
65:     def status
66:       unless @status
67:         h = primo_config["statuses"] unless primo_config.nil?
68:         @status = map(status_code, h)
69:       end
70:       return @status
71:     end

[Source]

    # File lib/exlibris/primo/holding.rb, line 94
94:     def to_a
95:       return [self]
96:     end

[Source]

     # File lib/exlibris/primo/holding.rb, line 98
 98:     def to_source
 99:       source_class = source_config["class_name"] unless source_config.nil?
100:       if source_class.nil?
101:         s = self
102:       else
103:         s = Exlibris::Primo::Source.const_get(source_class).new(self)
104:       end
105:       return s
106:     end

[Source]

    # File lib/exlibris/primo/holding.rb, line 77
77:     def url
78:       primo_url
79:     end

Protected Instance methods

[Source]

     # File lib/exlibris/primo/holding.rb, line 109
109:     def map(str, h=nil)
110:       return str if (h.nil? or !h.kind_of? Hash)
111:       return (h[str].nil? ? str : h[str])
112:     end

[Validate]