A wrapping around prism’s internal encoding data structures. This is used for reflection and debugging purposes.
The name of the encoding, that can be passed to Encoding.find.
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/debug.rb, line 214
def initialize(name, multibyte)
@name = name
@multibyte = multibyte
end
Initialize a new encoding with the given name and whether or not it is a multibyte encoding.
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/debug.rb, line 232
def alnum?(source)
Encoding._alnum?(name, source)
end
Returns true if the first character in the source string is a valid alphanumeric character for the encoding.
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/debug.rb, line 238
def alpha?(source)
Encoding._alpha?(name, source)
end
Returns true if the first character in the source string is a valid alphabetic character for the encoding.
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/debug.rb, line 220
def multibyte?
@multibyte
end
Whether or not the encoding is a multibyte encoding.
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/debug.rb, line 244
def upper?(source)
Encoding._upper?(name, source)
end
Returns true if the first character in the source string is a valid uppercase character for the encoding.
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/debug.rb, line 226
def width(source)
Encoding._width(name, source)
end
Returns the number of bytes of the first character in the source string, if it is valid for the encoding. Otherwise, returns 0.