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(*a) ⇒ 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.
1005 1006 1007 1008 |
# File 'lib/rbs/types.rb', line 1005 def initialize(literal:, location:) @literal = literal @location = location end |
Instance Attribute Details
#literal ⇒ Object (readonly)
Returns the value of attribute literal.
1002 1003 1004 |
# File 'lib/rbs/types.rb', line 1002 def literal @literal end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
1003 1004 1005 |
# File 'lib/rbs/types.rb', line 1003 def location @location end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
1010 1011 1012 |
# File 'lib/rbs/types.rb', line 1010 def ==(other) other.is_a?(Literal) && other.literal == literal end |
#hash ⇒ Object
1016 1017 1018 |
# File 'lib/rbs/types.rb', line 1016 def hash self.class.hash ^ literal.hash end |
#to_json(*a) ⇒ Object
1025 1026 1027 |
# File 'lib/rbs/types.rb', line 1025 def to_json(*a) { class: :literal, literal: literal.inspect, location: location }.to_json(*a) end |
#to_s(level = 0) ⇒ Object
1029 1030 1031 |
# File 'lib/rbs/types.rb', line 1029 def to_s(level = 0) literal.inspect end |