Class: Voyager::Holdings::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/holdings/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_node, leader) ⇒ Record

Record class initializing method Populates instance variables from the mfhd:marcRecord node of the mfhd:mfhdRecord node. Also instantiates Otem and Order classes for the mfhd:mfhdRecord node.

  • Args :

    • xml_node -> mfhd:mfhdRecord node



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/holdings/record.rb', line 15

def initialize(xml_node,leader)
  @bibid = xml_node.attributes["bibId"].value
  @holding_id = xml_node.attributes["mfhdId"].value
  @location_name = xml_node.at_css("mfhd|mfhdData[@name='locationDisplayName']").content
  location_code = xml_node.at_css("mfhd|mfhdData[@name='locationCode']").content
  # marc record node
  marc = xml_node.at_css("mfhd|marcRecord")

  # 852 holdings tag node
  tag852 = marc.at_css("slim|datafield[@tag='852']")
  # 866 holdings tag node
  tag866 = marc.css("slim|datafield[@tag='866']")

  @call_number = parse_call_number(tag852)    # string
  @summary_holdings = parse_summary_holdings(tag866)  # array
  @notes_852 = parse_notes_852(tag852)    # array
  @notes_866 = parse_notes_866(tag866)    # array
  # combine notes into a single array
  @notes = @notes_852 + @notes_866        # array
  @shelving_title = parse_shelving_title(tag852)  # string
  @supplements = parse_supplements(marc)    # array
  @indexes = parse_indexes(marc)    # array
  @reproduction_note = parse_reproduction_note(marc)    #string
  @urls = parse_urls(marc)    # array of hashes
  @donor_info = parse_donor_info(marc)  # array of hashes
  
  # information from item level records
  item = Item.new(xml_node)

  @item_count = item.item_count
  @temp_locations = item.temp_locations
  @item_status = item.item_status
  
  # flag for services processing (doc_delivery assignment)
  temp_loc_flag = 'N'
  # special case for single temp location
  if @item_count == '1' && (not @temp_locations.empty?)
    # temp location begins 'Shelved in' if it is not for a part
    if @temp_locations.first.match(/^Shelved/)
      # remove 'Shelved in' and replace location_name
      @location_name = @temp_locations.first.gsub(/^Shelved in /, '')
      @temp_locations.clear
      temp_loc_flag = 'Y'
    end
  end
  
  # set item status for online items
  if @location_name.match(/^Online/)
    @item_status[:status] = 'online'
    @item_status[:messages].clear
  end
  
  # information from order/receipt records
  order = Order.new(xml_node)
  
  @current_issues = order.current_issues
  @orders = order.orders
  
  # get format codes from leader
  fmt = leader[6..7]
  # add available services
  @services = determine_services(@location_name,location_code,temp_loc_flag,@call_number,@item_status,@orders,@bibid,fmt)
  
end

Instance Attribute Details

#bibidObject (readonly)

Returns the value of attribute bibid.



4
5
6
# File 'lib/holdings/record.rb', line 4

def bibid
  @bibid
end

#call_numberObject (readonly)

Returns the value of attribute call_number.



4
5
6
# File 'lib/holdings/record.rb', line 4

def call_number
  @call_number
end

#current_issuesObject (readonly)

Returns the value of attribute current_issues.



4
5
6
# File 'lib/holdings/record.rb', line 4

def current_issues
  @current_issues
end

#donor_infoObject (readonly)

Returns the value of attribute donor_info.



4
5
6
# File 'lib/holdings/record.rb', line 4

def donor_info
  @donor_info
end

#holding_idObject (readonly)

Returns the value of attribute holding_id.



4
5
6
# File 'lib/holdings/record.rb', line 4

def holding_id
  @holding_id
end

#indexesObject (readonly)

Returns the value of attribute indexes.



4
5
6
# File 'lib/holdings/record.rb', line 4

def indexes
  @indexes
end

#item_countObject (readonly)

Returns the value of attribute item_count.



4
5
6
# File 'lib/holdings/record.rb', line 4

def item_count
  @item_count
end

#item_statusObject (readonly)

Returns the value of attribute item_status.



4
5
6
# File 'lib/holdings/record.rb', line 4

def item_status
  @item_status
end

#location_nameObject (readonly)

Returns the value of attribute location_name.



4
5
6
# File 'lib/holdings/record.rb', line 4

def location_name
  @location_name
end

#notesObject (readonly)

Returns the value of attribute notes.



4
5
6
# File 'lib/holdings/record.rb', line 4

def notes
  @notes
end

#notes_852Object (readonly)

Returns the value of attribute notes_852.



4
5
6
# File 'lib/holdings/record.rb', line 4

def notes_852
  @notes_852
end

#notes_866Object (readonly)

Returns the value of attribute notes_866.



4
5
6
# File 'lib/holdings/record.rb', line 4

def notes_866
  @notes_866
end

#ordersObject (readonly)

Returns the value of attribute orders.



4
5
6
# File 'lib/holdings/record.rb', line 4

def orders
  @orders
end

#reproduction_noteObject (readonly)

Returns the value of attribute reproduction_note.



4
5
6
# File 'lib/holdings/record.rb', line 4

def reproduction_note
  @reproduction_note
end

#servicesObject (readonly)

Returns the value of attribute services.



4
5
6
# File 'lib/holdings/record.rb', line 4

def services
  @services
end

#shelving_titleObject (readonly)

Returns the value of attribute shelving_title.



4
5
6
# File 'lib/holdings/record.rb', line 4

def shelving_title
  @shelving_title
end

#summary_holdingsObject (readonly)

Returns the value of attribute summary_holdings.



4
5
6
# File 'lib/holdings/record.rb', line 4

def summary_holdings
  @summary_holdings
end

#supplementsObject (readonly)

Returns the value of attribute supplements.



4
5
6
# File 'lib/holdings/record.rb', line 4

def supplements
  @supplements
end

#temp_locationsObject (readonly)

Returns the value of attribute temp_locations.



4
5
6
# File 'lib/holdings/record.rb', line 4

def temp_locations
  @temp_locations
end

#urlsObject (readonly)

Returns the value of attribute urls.



4
5
6
# File 'lib/holdings/record.rb', line 4

def urls
  @urls
end

Instance Method Details

#to_hashObject

Collect data from all variables into a hash

  • Returns :

    • Hash



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/holdings/record.rb', line 85

def to_hash
  {
    :bibid => @bibid,
    :holding_id => @holding_id,
    :location_name => @location_name,
    :call_number => @call_number,
    :shelving_title => @shelving_title,
    :summary_holdings => @summary_holdings,
    :supplements => @supplements,
    :indexes => @indexes,
    :notes => @notes,
    :reproduction_note => @reproduction_note,
    :urls => @urls,
    :donor_info => @donor_info,
    :item_count => @item_count,
    :temp_locations => @temp_locations,
    :item_status => @item_status,
    :services => @services,
    :current_issues => @current_issues,
    :orders => @orders
  }
end