class Sip2::Messages::Status

Sip2 Patron information message

developers.exlibrisgroup.com/wp-content/uploads/2020/01/3M-Standard-Interchange-Protocol-Version-2.00.pdf

Request message 99

* status code      - 1 char, fixed-length required field: 0, 1 or 2
* max print width  - 3 char, fixed-length required field
* protocol version - 4 char, fixed-length required field: x.xx

Constants

STATUS_CODE_LOOKUP

Private Instance Methods

build_message(status_code: :ok, max_print_width: 999, protocol_version: 2) click to toggle source
# File lib/sip2/messages/status.rb, line 24
def build_message(status_code: :ok, max_print_width: 999, protocol_version: 2)
  [
    '99', # SC Status
    normalize_status_code(status_code),
    normalize_print_width(max_print_width),
    normalize_protocol_version(protocol_version)
  ].join
end
handle_response(response) click to toggle source
# File lib/sip2/messages/status.rb, line 48
def handle_response(response)
  return unless /\A#{Sip2::Responses::Status::RESPONSE_ID}/o.match?(response)

  Sip2::Responses::Status.new response
end
normalize_print_width(width) click to toggle source
# File lib/sip2/messages/status.rb, line 40
def normalize_print_width(width)
  format('%03<width>d', width: width % 1000)
end
normalize_protocol_version(version) click to toggle source
# File lib/sip2/messages/status.rb, line 44
def normalize_protocol_version(version)
  format('%.2<version>f', version: version % 10)
end
normalize_status_code(code) click to toggle source
# File lib/sip2/messages/status.rb, line 33
def normalize_status_code(code)
  format(
    '%<code>d',
    code: (code.is_a?(Symbol) ? STATUS_CODE_LOOKUP[code] : code).to_i.abs
  )[0]
end