Sha256: 58032f75d7c1b5a60fbd667bdeeacb38e526198ab44f97e222534fc7c16554c6
Contents?: true
Size: 826 Bytes
Versions: 11
Compression:
Stored size: 826 Bytes
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require "alma/electronic" module Alma # Holds some custom business logic for our Alma Electronic API. # This class is not intended for public use. class Electronic::Business # The Service ID is usually the Collection ID grouped by # 2 digits with the first number incremented by 1 and the # fifth number decremented by 1. # # @note However, this pattern does not hold for all cases. # # @param collection_id [String] The electronic collection id. def service_id(collection_id) collection_id.scan(/.{1,2}/).each_with_index.map { |char, index| if index == 0 "%02d" % (char.to_i + 1) elsif index == 4 "%02d" % (char.to_i - 1) else char end }.join end end end
Version data entries
11 entries across 11 versions & 1 rubygems