class Prism::StringQuery

that it can maintain a consistent interface
Here we are going to patch StringQuery to put in the class-level methods so

def constant?(string)

Mirrors the C extension's StringQuery::constant? method.
def constant?(string)
  query(LibRubyParser.pm_string_query_constant(string, string.bytesize, string.encoding.name))
end

def constant?

Whether or not this string is a valid constant name.
def constant?
  StringQuery.constant?(string)
end

def initialize(string)

Initialize a new query with the given string.
def initialize(string)
  @string = string
end

def local?(string)

Mirrors the C extension's StringQuery::local? method.
def local?(string)
  query(LibRubyParser.pm_string_query_local(string, string.bytesize, string.encoding.name))
end

def local?

Whether or not this string is a valid local variable name.
def local?
  StringQuery.local?(string)
end

def method_name?(string)

Mirrors the C extension's StringQuery::method_name? method.
def method_name?(string)
  query(LibRubyParser.pm_string_query_method_name(string, string.bytesize, string.encoding.name))
end

def method_name?

Whether or not this string is a valid method name.
def method_name?
  StringQuery.method_name?(string)
end

def query(result)

Parse the enum result and return an appropriate boolean.
def query(result)
  case result
  when :PM_STRING_QUERY_ERROR
    raise ArgumentError, "Invalid or non ascii-compatible encoding"
  when :PM_STRING_QUERY_FALSE
    false
  when :PM_STRING_QUERY_TRUE
    true
  end
end