Class: Alma::BibItem

Inherits:
Object
  • 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

Methods included from ApiDefaults

apikey, bibs_base_path, headers, region, timeout, users_base_path

Constructor Details

#initialize(item) ⇒ BibItem

Returns a new instance of BibItem.



23
24
25
# File 'lib/alma/bib_item.rb', line 23

def initialize(item)
  @item = item
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



7
8
9
# File 'lib/alma/bib_item.rb', line 7

def item
  @item
end

Class Method Details

.find(mms_id, options = {}) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/alma/bib_item.rb', line 15

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 = HTTParty.get(url, headers: headers, query: options, timeout: timeout)
  BibItemSet.new(response, options.merge({mms_id: mms_id, holding_id: holding_id}))
end

Instance Method Details

#alt_call_numberObject



107
108
109
# File 'lib/alma/bib_item.rb', line 107

def alt_call_number
  item_data.fetch("alternative_call_number","")
end

#base_statusObject



123
124
125
# File 'lib/alma/bib_item.rb', line 123

def base_status
  item_data.dig("base_status","value")|| ""
end

#call_numberObject



95
96
97
98
99
100
101
# File 'lib/alma/bib_item.rb', line 95

def call_number
  if has_temp_call_number?
    holding_data.fetch("temp_call_number")
  else
    holding_data.fetch("call_number","")
  end
end

#circulation_policyObject



131
132
133
# File 'lib/alma/bib_item.rb', line 131

def circulation_policy
  item_data.dig("policy", "desc") || ""
end

#descriptionObject



139
140
141
# File 'lib/alma/bib_item.rb', line 139

def description
  item_data.fetch("description", "")
end

#has_alt_call_number?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/alma/bib_item.rb', line 103

def has_alt_call_number?
  !alt_call_number.empty?
end

#has_process_type?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/alma/bib_item.rb', line 111

def has_process_type?
  !process_type.empty?
end

#has_temp_call_number?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/alma/bib_item.rb', line 91

def has_temp_call_number?
  !temp_call_number.empty?
end

#holding_dataObject



27
28
29
# File 'lib/alma/bib_item.rb', line 27

def holding_data
  @item.fetch("holding_data", {})
end

#holding_libraryObject



55
56
57
# File 'lib/alma/bib_item.rb', line 55

def holding_library
  item_data.dig("library", "value")
end

#holding_library_nameObject



59
60
61
# File 'lib/alma/bib_item.rb', line 59

def holding_library_name
  item_data.dig("library", "desc")
end

#holding_locationObject



63
64
65
# File 'lib/alma/bib_item.rb', line 63

def holding_location
  item_data.dig("location", "value")
end

#holding_location_nameObject



67
68
69
# File 'lib/alma/bib_item.rb', line 67

def holding_location_name
  item_data.dig("location", "desc")
end

#in_place?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/alma/bib_item.rb', line 127

def in_place?
  base_status == "1"
end

#in_temp_location?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/alma/bib_item.rb', line 35

def in_temp_location?
  holding_data.fetch("in_temp_location", false)
end

#item_dataObject



31
32
33
# File 'lib/alma/bib_item.rb', line 31

def item_data
  @item.fetch("item_data", {})
end

#libraryObject



39
40
41
# File 'lib/alma/bib_item.rb', line 39

def library
  in_temp_location? ? temp_library : holding_library
end

#library_nameObject



43
44
45
# File 'lib/alma/bib_item.rb', line 43

def library_name
  in_temp_location? ? temp_library_name : holding_library_name
end

#locationObject



47
48
49
# File 'lib/alma/bib_item.rb', line 47

def location
  in_temp_location? ? temp_location : holding_location
end

#location_nameObject



51
52
53
# File 'lib/alma/bib_item.rb', line 51

def location_name
  in_temp_location? ? temp_location_name : holding_location_name
end

#missing_or_lost?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/alma/bib_item.rb', line 119

def missing_or_lost?
  !!process_type.match(/MISSING|LOST_LOAN/)
end

#non_circulating?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/alma/bib_item.rb', line 135

def non_circulating?
  circulation_policy.include?("Non-circulating")
end

#physical_material_typeObject



143
144
145
# File 'lib/alma/bib_item.rb', line 143

def physical_material_type
  item_data.fetch("physical_material_type", "")
end

#process_typeObject



115
116
117
# File 'lib/alma/bib_item.rb', line 115

def process_type
  item_data.dig("process_type", "value") || ""
end

#public_noteObject



147
148
149
# File 'lib/alma/bib_item.rb', line 147

def public_note
  item_data.fetch("public_note", "")
end

#temp_call_numberObject



87
88
89
# File 'lib/alma/bib_item.rb', line 87

def temp_call_number
  holding_data.fetch("temp_call_number","")
end

#temp_libraryObject



71
72
73
# File 'lib/alma/bib_item.rb', line 71

def temp_library
  holding_data.dig("temp_library", "value")
end

#temp_library_nameObject



75
76
77
# File 'lib/alma/bib_item.rb', line 75

def temp_library_name
  holding_data.dig("temp_library", "desc")
end

#temp_locationObject



79
80
81
# File 'lib/alma/bib_item.rb', line 79

def temp_location
  holding_data.dig("temp_location", "value")
end

#temp_location_nameObject



83
84
85
# File 'lib/alma/bib_item.rb', line 83

def temp_location_name
  holding_data.dig("temp_location", "desc")
end