summaryrefslogtreecommitdiff
path: root/lib/prism/polyfill/scan_byte.rb
blob: 2def4572c428703078d694495d06c3c8b216c0de (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.instance_methods.include?(:scan_byte))
  StringScanner.include(
    Module.new {
      def scan_byte # :nodoc:
        get_byte&.b&.ord
      end
    }
  )
end