Class: MilkTea::AST::TypeRef
- Inherits:
-
Object
- Object
- MilkTea::AST::TypeRef
- Defined in:
- lib/milk_tea/core/ast.rb
Instance Method Summary collapse
-
#initialize(name:, arguments:, nullable:, lifetime: nil, line: nil, column: nil, length: nil) ⇒ TypeRef
constructor
A new instance of TypeRef.
- #to_s ⇒ Object
Constructor Details
#initialize(name:, arguments:, nullable:, lifetime: nil, line: nil, column: nil, length: nil) ⇒ TypeRef
Returns a new instance of TypeRef.
24 |
# File 'lib/milk_tea/core/ast.rb', line 24 def initialize(name:, arguments:, nullable:, lifetime: nil, line: nil, column: nil, length: nil) = super |
Instance Method Details
#to_s ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/milk_tea/core/ast.rb', line 26 def to_s text = name.to_s args = [] args << lifetime if lifetime args.concat(arguments.map do |argument| value = argument.value case value when IntegerLiteral, FloatLiteral then value.lexeme else value.to_s end end) unless args.empty? text += "[#{args.join(', ')}]" end nullable ? "#{text}?" : text end |