class Prism::StringQuery
Here we are going to patchStringQuery to put in the class-level methods so that it can maintain a consistent interface
Query methods that allow categorizing strings based on their context for where they could be valid in a Ruby syntax tree.
Attributes
The string that this query is wrapping.
Public Class Methods
Source
# File lib/prism/ffi.rb, line 552defconstant?(string)query(LibRubyParser.pm_string_query_constant(string,string.bytesize,string.encoding.name))end
Mirrors the C extension’sStringQuery::constant? method.
Source
# File lib/prism/ffi.rb, line 547deflocal?(string)query(LibRubyParser.pm_string_query_local(string,string.bytesize,string.encoding.name))end
Mirrors the C extension’sStringQuery::local? method.
Source
# File lib/prism/ffi.rb, line 557defmethod_name?(string)query(LibRubyParser.pm_string_query_method_name(string,string.bytesize,string.encoding.name))end
Mirrors the C extension’sStringQuery::method_name? method.
Source
# File lib/prism/string_query.rb, line 12definitialize(string)@string =stringend
Initialize a new query with the given string.
Private Class Methods
Source
# File lib/prism/ffi.rb, line 564defquery(result)caseresultwhen:PM_STRING_QUERY_ERRORraiseArgumentError,"Invalid or non ascii-compatible encoding"when:PM_STRING_QUERY_FALSEfalsewhen:PM_STRING_QUERY_TRUEtrueendend
Parse the enum result and return an appropriate boolean.
Public Instance Methods
Source
# File lib/prism/string_query.rb, line 22defconstant?StringQuery.constant?(string)end
Whether or not this string is a valid constant name.
Source
# File lib/prism/string_query.rb, line 17deflocal?StringQuery.local?(string)end
Whether or not this string is a valid local variable name.
Source
# File lib/prism/string_query.rb, line 27defmethod_name?StringQuery.method_name?(string)end
Whether or not this string is a valid method name.