Class: Alma::BibItem
- Inherits:
-
Object
- Object
- Alma::BibItem
- Extended by:
- 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
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Class Method Summary collapse
Instance Method Summary collapse
- #alt_call_number ⇒ Object
- #base_status ⇒ Object
- #call_number ⇒ Object
- #circulation_policy ⇒ Object
- #description ⇒ Object
- #has_alt_call_number? ⇒ Boolean
- #has_process_type? ⇒ Boolean
- #has_temp_call_number? ⇒ Boolean
- #holding_data ⇒ Object
- #holding_library ⇒ Object
- #holding_library_name ⇒ Object
- #holding_location ⇒ Object
- #holding_location_name ⇒ Object
- #in_place? ⇒ Boolean
- #in_temp_location? ⇒ Boolean
-
#initialize(item) ⇒ BibItem
constructor
A new instance of BibItem.
- #item_data ⇒ Object
- #library ⇒ Object
- #library_name ⇒ Object
- #location ⇒ Object
- #location_name ⇒ Object
- #missing_or_lost? ⇒ Boolean
- #non_circulating? ⇒ Boolean
- #physical_material_type ⇒ Object
- #process_type ⇒ Object
- #public_note ⇒ Object
- #temp_call_number ⇒ Object
- #temp_library ⇒ Object
- #temp_library_name ⇒ Object
- #temp_location ⇒ Object
- #temp_location_name ⇒ Object
Constructor Details
#initialize(item) ⇒ BibItem
Returns a new instance of BibItem.
22 23 24 |
# File 'lib/alma/bib_item.rb', line 22 def initialize(item) @item = item end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
6 7 8 |
# File 'lib/alma/bib_item.rb', line 6 def item @item end |
Class Method Details
.find(mms_id, options = {}) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/alma/bib_item.rb', line 14 def self.find(mms_id, ={}) holding_id = .delete(:holding_id) || "ALL" .select! {|k,_| PERMITTED_ARGS.include? k } url = "#{bibs_base_path}/#{mms_id}/holdings/#{holding_id}/items" response = HTTParty.get(url, headers: headers, query: ) BibItemSet.new(response) end |
Instance Method Details
#alt_call_number ⇒ Object
109 110 111 |
# File 'lib/alma/bib_item.rb', line 109 def alt_call_number item_data.fetch("alternative_call_number","") end |
#base_status ⇒ Object
125 126 127 |
# File 'lib/alma/bib_item.rb', line 125 def base_status item_data.dig("base_status","value")|| "" end |
#call_number ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/alma/bib_item.rb', line 95 def call_number if has_temp_call_number? holding_data.fetch("temp_call_number") elsif has_alt_call_number? alt_call_number else holding_data.fetch("call_number","") end end |
#circulation_policy ⇒ Object
133 134 135 |
# File 'lib/alma/bib_item.rb', line 133 def circulation_policy item_data.dig("policy", "desc") || "" end |
#description ⇒ Object
141 142 143 |
# File 'lib/alma/bib_item.rb', line 141 def description item_data.fetch("description", "") end |
#has_alt_call_number? ⇒ Boolean
105 106 107 |
# File 'lib/alma/bib_item.rb', line 105 def has_alt_call_number? !alt_call_number.empty? end |
#has_process_type? ⇒ Boolean
113 114 115 |
# File 'lib/alma/bib_item.rb', line 113 def has_process_type? !process_type.empty? end |
#has_temp_call_number? ⇒ Boolean
91 92 93 |
# File 'lib/alma/bib_item.rb', line 91 def has_temp_call_number? !temp_call_number.empty? end |
#holding_data ⇒ Object
26 27 28 |
# File 'lib/alma/bib_item.rb', line 26 def holding_data @item.fetch("holding_data", {}) end |
#holding_library ⇒ Object
55 56 57 |
# File 'lib/alma/bib_item.rb', line 55 def holding_library item_data.dig("library", "value") end |
#holding_library_name ⇒ Object
59 60 61 |
# File 'lib/alma/bib_item.rb', line 59 def holding_library_name item_data.dig("library", "desc") end |
#holding_location ⇒ Object
63 64 65 |
# File 'lib/alma/bib_item.rb', line 63 def holding_location item_data.dig("location", "value") end |
#holding_location_name ⇒ Object
67 68 69 |
# File 'lib/alma/bib_item.rb', line 67 def holding_location_name item_data.dig("location", "desc") end |
#in_place? ⇒ Boolean
129 130 131 |
# File 'lib/alma/bib_item.rb', line 129 def in_place? base_status == "1" end |
#in_temp_location? ⇒ Boolean
34 35 36 |
# File 'lib/alma/bib_item.rb', line 34 def in_temp_location? holding_data.fetch("in_temp_location", false) end |
#item_data ⇒ Object
30 31 32 |
# File 'lib/alma/bib_item.rb', line 30 def item_data @item.fetch("item_data", {}) end |
#library ⇒ Object
38 39 40 |
# File 'lib/alma/bib_item.rb', line 38 def library in_temp_location? ? temp_library : holding_library end |
#library_name ⇒ Object
42 43 44 |
# File 'lib/alma/bib_item.rb', line 42 def library_name in_temp_location? ? temp_library_name : holding_library_name end |
#location ⇒ Object
46 47 48 |
# File 'lib/alma/bib_item.rb', line 46 def location in_temp_location? ? temp_location : holding_location end |
#location_name ⇒ Object
50 51 52 |
# File 'lib/alma/bib_item.rb', line 50 def location_name in_temp_location? ? temp_location_name : holding_location_name end |
#missing_or_lost? ⇒ Boolean
121 122 123 |
# File 'lib/alma/bib_item.rb', line 121 def missing_or_lost? !!process_type.match(/MISSING|LOST_LOAN/) end |
#non_circulating? ⇒ Boolean
137 138 139 |
# File 'lib/alma/bib_item.rb', line 137 def non_circulating? circulation_policy.include?("Non-circulating") end |
#physical_material_type ⇒ Object
145 146 147 |
# File 'lib/alma/bib_item.rb', line 145 def physical_material_type item_data.fetch("physical_material_type", "") end |
#process_type ⇒ Object
117 118 119 |
# File 'lib/alma/bib_item.rb', line 117 def process_type item_data.dig("process_type", "value") || "" end |
#public_note ⇒ Object
149 150 151 |
# File 'lib/alma/bib_item.rb', line 149 def public_note item_data.fetch("public_note", "") end |
#temp_call_number ⇒ Object
87 88 89 |
# File 'lib/alma/bib_item.rb', line 87 def temp_call_number holding_data.fetch("temp_call_number","") end |
#temp_library ⇒ Object
71 72 73 |
# File 'lib/alma/bib_item.rb', line 71 def temp_library holding_data.dig("temp_library", "value") end |
#temp_library_name ⇒ Object
75 76 77 |
# File 'lib/alma/bib_item.rb', line 75 def temp_library_name holding_data.dig("temp_library", "desc") end |
#temp_location ⇒ Object
79 80 81 |
# File 'lib/alma/bib_item.rb', line 79 def temp_location holding_data.dig("temp_location", "value") end |
#temp_location_name ⇒ Object
83 84 85 |
# File 'lib/alma/bib_item.rb', line 83 def temp_location_name holding_data.dig("temp_location", "desc") end |