Debian Codegraph @

lib/prism/polyfill/unpack1.rb

raw symbols SCIP
1 # frozen_string_literal: true
2
3 # Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines
4 # have Method#parameters implemented, so we check the arity instead if
5 # necessary.
6 if (unpack1 = String.instance_method(:unpack1)).respond_to?(:parameters) ? unpack1.parameters.none? { |_, name| name == :offset } : (unpack1.arity == 1)
7 String.prepend(
8 Module.new {
9 def unpack1(format, offset: 0) # :nodoc:
10 offset == 0 ? super(format) : self[offset..].unpack1(format) # steep:ignore
11 end
12 }
13 )
14 end