summaryrefslogtreecommitdiff
path: root/lib/prism/polyfill/string.rb
blob: 582266d9566549ec858d0671eca651a7ba663b0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# frozen_string_literal: true

# Polyfill for String#unpack1 with the offset parameter.
if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset }
  String.prepend(
    Module.new {
      def unpack1(format, offset: 0) # :nodoc:
        offset == 0 ? super(format) : self[offset..].unpack1(format) # steep:ignore
      end
    }
  )
end