class Shelvit
Generates normalized shelf keys from call numbers, using the Lcsort gem.
Constants
- LOWER_MAP
- VERSION
Public Class Methods
normalize(call_number)
click to toggle source
# File lib/shelvit.rb, line 9 def self.normalize(call_number) return if call_number.nil? Lcsort.normalize(call_number) || Lcsort.normalize(cleaned(call_number)) end
Private Class Methods
cleaned(call_number)
click to toggle source
@note If Lcsort can’t properly normalize the call number, we “clean” it up by translating unsortable characters into sortable ones:
-
Lower-case letters are translated into numbers 00 through 25. Ex. PZ7.H56774Fz becomes PZ7.H56774F25
-
Colons are replaced with periods
-
LC numbers that have no number after their letter classification have a ‘0’ added. Ex, KKP.B634 becomes KKP0.B634
# File lib/shelvit.rb, line 22 def self.cleaned(call_number) call_number .gsub(/([a-z])/, LOWER_MAP) .gsub(/:/, '.') .gsub(/(^[A-Z]{1,3})\.([A-Z])/, '\10.\2') end