class RBS::Types::Literal

Constants

TABLE

Attributes

literal[R]
location[R]

Public Class Methods

new(literal:, location:) click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1486
def initialize(literal:, location:)
  @literal = literal
  @location = location
end
unescape_string(string, is_double_quote) click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1542
def self.unescape_string(string, is_double_quote)
  if is_double_quote
    string.gsub!(/\\([0-9]{1,3})/) { ($1 || "").to_i(8).chr }
    string.gsub!(/\\x([0-9a-f]{1,2})/) { ($1 || "").to_i(16).chr }
    string.gsub!(/\\u([0-9a-fA-F]{4})/) { ($1 || "").to_i(16).chr(Encoding::UTF_8) }
    string.gsub!(/\\[abefnrstv"'\\]?/, TABLE)
    string
  else
    string.gsub!(/\\['\\]/, TABLE)
    string
  end
end

Public Instance Methods

==(other) click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1491
def ==(other)
  other.is_a?(Literal) && other.literal == literal
end
Also aliased as: eql?
eql?(other)
Alias for: ==
has_classish_type?() click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1518
def has_classish_type?
  false
end
has_self_type?() click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1514
def has_self_type?
  false
end
hash() click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1497
def hash
  self.class.hash ^ literal.hash
end
to_json(state = _ = nil) click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1506
def to_json(state = _ = nil)
  { class: :literal, literal: literal.inspect, location: location }.to_json(state)
end
to_s(level = 0) click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1510
def to_s(level = 0)
  literal.inspect
end
with_nonreturn_void?() click to toggle source
# File rbs-3.7.0/lib/rbs/types.rb, line 1522
def with_nonreturn_void?
  false
end