summaryrefslogtreecommitdiff
path: root/lib/prism/polyfill/scan_byte.rb
blob: 9276e509fccb7df9e5ff03d4296bf934a9b9c69a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

require "strscan"

# Polyfill for StringScanner#scan_byte, which didn't exist until Ruby 3.4.
if !(StringScanner.method_defined?(:scan_byte))
  StringScanner.include(
    Module.new {
      def scan_byte # :nodoc:
        get_byte&.b&.ord
      end
    }
  )
end