class Prism::Debug::Encoding

A wrapping around prism’s internal encoding data structures. This is used for reflection and debugging purposes.

Attributes

name[R]

The name of the encoding, that can be passed to Encoding.find.

Public Class Methods

new(name, multibyte) click to toggle source

Initialize a new encoding with the given name and whether or not it is a multibyte encoding.

# File prism/debug.rb, line 214
def initialize(name, multibyte)
  @name = name
  @multibyte = multibyte
end

Public Instance Methods

alnum?(source) click to toggle source

Returns true if the first character in the source string is a valid alphanumeric character for the encoding.

# File prism/debug.rb, line 232
def alnum?(source)
  Encoding._alnum?(name, source)
end
alpha?(source) click to toggle source

Returns true if the first character in the source string is a valid alphabetic character for the encoding.

# File prism/debug.rb, line 238
def alpha?(source)
  Encoding._alpha?(name, source)
end
multibyte?() click to toggle source

Whether or not the encoding is a multibyte encoding.

# File prism/debug.rb, line 220
def multibyte?
  @multibyte
end
upper?(source) click to toggle source

Returns true if the first character in the source string is a valid uppercase character for the encoding.

# File prism/debug.rb, line 244
def upper?(source)
  Encoding._upper?(name, source)
end
width(source) click to toggle source

Returns the number of bytes of the first character in the source string, if it is valid for the encoding. Otherwise, returns 0.

# File prism/debug.rb, line 226
def width(source)
  Encoding._width(name, source)
end