Class: Alma::BibItem
- Inherits:
-
Object
show all
- Extended by:
- ApiDefaults, Forwardable
- Defined in:
- lib/alma/bib_item.rb
Constant Summary
collapse
- PERMITTED_ARGS =
[
:limit, :offset, :expand, :user_id, :current_library,
:current_location, :q, :order_by, :direction
]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
apikey, bibs_base_path, configuration_base_path, headers, items_base_path, region, timeout, users_base_path
Constructor Details
#initialize(item) ⇒ BibItem
Returns a new instance of BibItem.
42
43
44
|
# File 'lib/alma/bib_item.rb', line 42
def initialize(item)
@item = item
end
|
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
9
10
11
|
# File 'lib/alma/bib_item.rb', line 9
def item
@item
end
|
Class Method Details
.find(mms_id, options = {}) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/alma/bib_item.rb', line 17
def self.find(mms_id, options = {})
holding_id = options.delete(:holding_id) || "ALL"
options.select! { |k, _| PERMITTED_ARGS.include? k }
url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items"
response = Net.get(url, headers:, query: options, timeout:)
BibItemSet.new(response, options.merge({ mms_id:, holding_id: }))
end
|
.find_by_barcode(barcode) ⇒ Object
31
32
33
34
|
# File 'lib/alma/bib_item.rb', line 31
def self.find_by_barcode(barcode)
response = Net.get(items_base_path, headers:, query: { item_barcode: barcode }, timeout:, follow_redirects: true)
new(response)
end
|
.find_one(mms_id:, holding_id:, item_pid:, options: {}) ⇒ Object
25
26
27
28
29
|
# File 'lib/alma/bib_item.rb', line 25
def self.find_one(mms_id:, holding_id:, item_pid:, options: {})
url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items/#{item_pid}"
response = Net.get(url, headers:, query: options, timeout:)
new(response)
end
|
.scan(mms_id:, holding_id:, item_pid:, options: {}) ⇒ Object
36
37
38
39
40
|
# File 'lib/alma/bib_item.rb', line 36
def self.scan(mms_id:, holding_id:, item_pid:, options: {})
url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items/#{item_pid}"
response = Net.post(url, headers:, query: options)
new(response)
end
|
Instance Method Details
#alt_call_number ⇒ Object
126
127
128
|
# File 'lib/alma/bib_item.rb', line 126
def alt_call_number
item_data.fetch("alternative_call_number", "")
end
|
#base_status ⇒ Object
142
143
144
|
# File 'lib/alma/bib_item.rb', line 142
def base_status
item_data.dig("base_status", "value") || ""
end
|
#call_number ⇒ Object
114
115
116
117
118
119
120
|
# File 'lib/alma/bib_item.rb', line 114
def call_number
if has_temp_call_number?
holding_data.fetch("temp_call_number")
else
holding_data.fetch("call_number", "")
end
end
|
#circulation_policy ⇒ Object
150
151
152
|
# File 'lib/alma/bib_item.rb', line 150
def circulation_policy
item_data.dig("policy", "desc") || ""
end
|
#description ⇒ Object
158
159
160
|
# File 'lib/alma/bib_item.rb', line 158
def description
item_data.fetch("description", "")
end
|
#has_alt_call_number? ⇒ Boolean
122
123
124
|
# File 'lib/alma/bib_item.rb', line 122
def has_alt_call_number?
!alt_call_number.empty?
end
|
#has_process_type? ⇒ Boolean
130
131
132
|
# File 'lib/alma/bib_item.rb', line 130
def has_process_type?
!process_type.empty?
end
|
#has_temp_call_number? ⇒ Boolean
110
111
112
|
# File 'lib/alma/bib_item.rb', line 110
def has_temp_call_number?
!temp_call_number.empty?
end
|
#holding_data ⇒ Object
46
47
48
|
# File 'lib/alma/bib_item.rb', line 46
def holding_data
@item.fetch("holding_data", {})
end
|
#holding_library ⇒ Object
74
75
76
|
# File 'lib/alma/bib_item.rb', line 74
def holding_library
item_data.dig("library", "value")
end
|
#holding_library_name ⇒ Object
78
79
80
|
# File 'lib/alma/bib_item.rb', line 78
def holding_library_name
item_data.dig("library", "desc")
end
|
#holding_location ⇒ Object
82
83
84
|
# File 'lib/alma/bib_item.rb', line 82
def holding_location
item_data.dig("location", "value")
end
|
#holding_location_name ⇒ Object
86
87
88
|
# File 'lib/alma/bib_item.rb', line 86
def holding_location_name
item_data.dig("location", "desc")
end
|
#in_place? ⇒ Boolean
146
147
148
|
# File 'lib/alma/bib_item.rb', line 146
def in_place?
base_status == "1"
end
|
#in_temp_location? ⇒ Boolean
54
55
56
|
# File 'lib/alma/bib_item.rb', line 54
def in_temp_location?
holding_data.fetch("in_temp_location", false)
end
|
#item_data ⇒ Object
50
51
52
|
# File 'lib/alma/bib_item.rb', line 50
def item_data
@item.fetch("item_data", {})
end
|
#library ⇒ Object
58
59
60
|
# File 'lib/alma/bib_item.rb', line 58
def library
in_temp_location? ? temp_library : holding_library
end
|
#library_name ⇒ Object
62
63
64
|
# File 'lib/alma/bib_item.rb', line 62
def library_name
in_temp_location? ? temp_library_name : holding_library_name
end
|
#location ⇒ Object
66
67
68
|
# File 'lib/alma/bib_item.rb', line 66
def location
in_temp_location? ? temp_location : holding_location
end
|
#location_name ⇒ Object
70
71
72
|
# File 'lib/alma/bib_item.rb', line 70
def location_name
in_temp_location? ? temp_location_name : holding_location_name
end
|
#missing_or_lost? ⇒ Boolean
138
139
140
|
# File 'lib/alma/bib_item.rb', line 138
def missing_or_lost?
!!process_type.match(/MISSING|LOST_LOAN/)
end
|
#non_circulating? ⇒ Boolean
154
155
156
|
# File 'lib/alma/bib_item.rb', line 154
def non_circulating?
circulation_policy.include?("Non-circulating")
end
|
#physical_material_type ⇒ Object
162
163
164
|
# File 'lib/alma/bib_item.rb', line 162
def physical_material_type
item_data.fetch("physical_material_type", "")
end
|
#process_type ⇒ Object
134
135
136
|
# File 'lib/alma/bib_item.rb', line 134
def process_type
item_data.dig("process_type", "value") || ""
end
|
#public_note ⇒ Object
166
167
168
|
# File 'lib/alma/bib_item.rb', line 166
def public_note
item_data.fetch("public_note", "")
end
|
#temp_call_number ⇒ Object
106
107
108
|
# File 'lib/alma/bib_item.rb', line 106
def temp_call_number
holding_data.fetch("temp_call_number", "")
end
|
#temp_library ⇒ Object
90
91
92
|
# File 'lib/alma/bib_item.rb', line 90
def temp_library
holding_data.dig("temp_library", "value")
end
|
#temp_library_name ⇒ Object
94
95
96
|
# File 'lib/alma/bib_item.rb', line 94
def temp_library_name
holding_data.dig("temp_library", "desc")
end
|
#temp_location ⇒ Object
98
99
100
|
# File 'lib/alma/bib_item.rb', line 98
def temp_location
holding_data.dig("temp_location", "value")
end
|
#temp_location_name ⇒ Object
102
103
104
|
# File 'lib/alma/bib_item.rb', line 102
def temp_location_name
holding_data.dig("temp_location", "desc")
end
|