Class: RBS::Types::Literal

Inherits:
Object
  • Object
show all
Includes:
EmptyEachType, NoFreeVariables, NoSubst, NoTypeName
Defined in:
lib/rbs/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NoTypeName

#map_type_name

Methods included from EmptyEachType

#each_type

Methods included from NoSubst

#sub

Methods included from NoFreeVariables

#free_variables

Constructor Details

#initialize(literal:, location:) ⇒ Literal

Returns a new instance of Literal.



1067
1068
1069
1070
# File 'lib/rbs/types.rb', line 1067

def initialize(literal:, location:)
  @literal = literal
  @location = location
end

Instance Attribute Details

#literalObject (readonly)

Returns the value of attribute literal.



1064
1065
1066
# File 'lib/rbs/types.rb', line 1064

def literal
  @literal
end

#locationObject (readonly)

Returns the value of attribute location.



1065
1066
1067
# File 'lib/rbs/types.rb', line 1065

def location
  @location
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



1072
1073
1074
# File 'lib/rbs/types.rb', line 1072

def ==(other)
  other.is_a?(Literal) && other.literal == literal
end

#hashObject



1078
1079
1080
# File 'lib/rbs/types.rb', line 1078

def hash
  self.class.hash ^ literal.hash
end

#to_json(state = _ = nil) ⇒ Object



1087
1088
1089
# File 'lib/rbs/types.rb', line 1087

def to_json(state = _ = nil)
  { class: :literal, literal: literal.inspect, location: location }.to_json(state)
end

#to_s(level = 0) ⇒ Object



1091
1092
1093
# File 'lib/rbs/types.rb', line 1091

def to_s(level = 0)
  literal.inspect
end