Class: RBS::Types::Literal
- Inherits:
-
Object
- Object
- RBS::Types::Literal
- Includes:
- EmptyEachType, NoFreeVariables, NoSubst, NoTypeName
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#literal ⇒ Object
readonly
Returns the value of attribute literal.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(literal:, location:) ⇒ Literal
constructor
A new instance of Literal.
- #to_json(state = _ = nil) ⇒ Object
- #to_s(level = 0) ⇒ Object
Methods included from NoTypeName
Methods included from EmptyEachType
Methods included from NoSubst
Methods included from NoFreeVariables
Constructor Details
#initialize(literal:, location:) ⇒ Literal
Returns a new instance of Literal.
1194 1195 1196 1197 |
# File 'lib/rbs/types.rb', line 1194 def initialize(literal:, location:) @literal = literal @location = location end |
Instance Attribute Details
#literal ⇒ Object (readonly)
Returns the value of attribute literal.
1191 1192 1193 |
# File 'lib/rbs/types.rb', line 1191 def literal @literal end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
1192 1193 1194 |
# File 'lib/rbs/types.rb', line 1192 def location @location end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
1199 1200 1201 |
# File 'lib/rbs/types.rb', line 1199 def ==(other) other.is_a?(Literal) && other.literal == literal end |
#hash ⇒ Object
1205 1206 1207 |
# File 'lib/rbs/types.rb', line 1205 def hash self.class.hash ^ literal.hash end |
#to_json(state = _ = nil) ⇒ Object
1214 1215 1216 |
# File 'lib/rbs/types.rb', line 1214 def to_json(state = _ = nil) { class: :literal, literal: literal.inspect, location: location }.to_json(state) end |
#to_s(level = 0) ⇒ Object
1218 1219 1220 |
# File 'lib/rbs/types.rb', line 1218 def to_s(level = 0) literal.inspect end |