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, #map_type

Methods included from NoSubst

#sub

Methods included from NoFreeVariables

#free_variables

Constructor Details

#initialize(literal:, location:) ⇒ Literal

Returns a new instance of Literal.



1190
1191
1192
1193
# File 'lib/rbs/types.rb', line 1190

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

Instance Attribute Details

#literalObject (readonly)

Returns the value of attribute literal.



1187
1188
1189
# File 'lib/rbs/types.rb', line 1187

def literal
  @literal
end

#locationObject (readonly)

Returns the value of attribute location.



1188
1189
1190
# File 'lib/rbs/types.rb', line 1188

def location
  @location
end

Instance Method Details

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



1195
1196
1197
# File 'lib/rbs/types.rb', line 1195

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

#hashObject



1201
1202
1203
# File 'lib/rbs/types.rb', line 1201

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

#to_json(state = _ = nil) ⇒ Object



1210
1211
1212
# File 'lib/rbs/types.rb', line 1210

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

#to_s(level = 0) ⇒ Object



1214
1215
1216
# File 'lib/rbs/types.rb', line 1214

def to_s(level = 0)
  literal.inspect
end