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.



999
1000
1001
1002
# File 'lib/rbs/types.rb', line 999

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

Instance Attribute Details

#literalObject (readonly)

Returns the value of attribute literal.



996
997
998
# File 'lib/rbs/types.rb', line 996

def literal
  @literal
end

#locationObject (readonly)

Returns the value of attribute location.



997
998
999
# File 'lib/rbs/types.rb', line 997

def location
  @location
end

Instance Method Details

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



1004
1005
1006
# File 'lib/rbs/types.rb', line 1004

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

#hashObject



1010
1011
1012
# File 'lib/rbs/types.rb', line 1010

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

#to_json(*a) ⇒ Object



1019
1020
1021
# File 'lib/rbs/types.rb', line 1019

def to_json(*a)
  { class: :literal, literal: literal.inspect, location: location }.to_json(*a)
end

#to_s(level = 0) ⇒ Object



1023
1024
1025
# File 'lib/rbs/types.rb', line 1023

def to_s(level = 0)
  literal.inspect
end