Class: Synthra::Parser::AST::TypeNode
- Defined in:
- lib/synthra/parser/ast.rb
Overview
Type reference node
Represents a type declaration with optional arguments. This is the base class for type nodes; ArrayTypeNode and CustomNode extend it for special cases.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
Instance Method Summary collapse
-
#initialize(name:, arguments: {}, nullable: false, line: nil) ⇒ TypeNode
constructor
Create a new TypeNode.
-
#nullable? ⇒ Boolean
Check if this type can be null.
Constructor Details
#initialize(name:, arguments: {}, nullable: false, line: nil) ⇒ TypeNode
Create a new TypeNode
326 327 328 329 330 331 |
# File 'lib/synthra/parser/ast.rb', line 326 def initialize(name:, arguments: {}, nullable: false, line: nil) super(line: line) @name = name.to_s.delete_suffix("?") @nullable = nullable || name.to_s.end_with?("?") @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
310 311 312 |
# File 'lib/synthra/parser/ast.rb', line 310 def arguments @arguments end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
304 305 306 |
# File 'lib/synthra/parser/ast.rb', line 304 def name @name end |
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
316 317 318 |
# File 'lib/synthra/parser/ast.rb', line 316 def nullable @nullable end |
Instance Method Details
#nullable? ⇒ Boolean
Check if this type can be null
338 339 340 |
# File 'lib/synthra/parser/ast.rb', line 338 def nullable? @nullable end |