Class: Alma::LoanSet

Inherits:
Object
  • Object
show all
Defined in:
lib/alma/loan_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ws_response) ⇒ LoanSet

Returns a new instance of LoanSet.



6
7
8
9
10
# File 'lib/alma/loan_set.rb', line 6

def initialize(ws_response)
  @ws_response = ws_response
  @total_record_count = ws_response.fetch('total_record_count', 0)
  @list ||= list_results
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



4
5
6
# File 'lib/alma/loan_set.rb', line 4

def list
  @list
end

#total_record_countObject (readonly)

Returns the value of attribute total_record_count.



4
5
6
# File 'lib/alma/loan_set.rb', line 4

def total_record_count
  @total_record_count
end

Instance Method Details

#list_resultsObject



16
17
18
19
20
# File 'lib/alma/loan_set.rb', line 16

def list_results
  response_records.map do |loan|
    Alma::Loan.new(loan)
  end
end

#response_recordsObject



12
13
14
# File 'lib/alma/loan_set.rb', line 12

def response_records
  @ws_response['item_loans'].fetch('item_loan',[])
end