Class: RBS::Inline::AST::Annotations::VarType
- Defined in:
- lib/rbs/inline/ast/annotations.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
: String?.
-
#name ⇒ Object
readonly
: Symbol.
-
#type ⇒ Object
readonly
: Types::t?.
Attributes inherited from Base
Instance Method Summary collapse
-
#complete? ⇒ Boolean
: () -> bool.
-
#initialize(tree, source) ⇒ VarType
constructor
A new instance of VarType.
Constructor Details
#initialize(tree, source) ⇒ VarType
Returns a new instance of VarType.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/rbs/inline/ast/annotations.rb', line 131 def initialize(tree, source) @tree = tree @source = source lvar_tree = tree.nth_tree!(1) # :tLVAR doesn't have `!` prefix # :tELVAR has `!` prefix to escape keywords @name = lvar_tree.nth_token!(0)[1].delete_prefix("!").to_sym if type = lvar_tree.nth_type?(2) @type = type end if comment = lvar_tree.nth_tree(3) @comment = comment.to_s end end |
Instance Attribute Details
#comment ⇒ Object (readonly)
: String?
128 129 130 |
# File 'lib/rbs/inline/ast/annotations.rb', line 128 def comment @comment end |
#name ⇒ Object (readonly)
: Symbol
124 125 126 |
# File 'lib/rbs/inline/ast/annotations.rb', line 124 def name @name end |
#type ⇒ Object (readonly)
: Types::t?
126 127 128 |
# File 'lib/rbs/inline/ast/annotations.rb', line 126 def type @type end |
Instance Method Details
#complete? ⇒ Boolean
: () -> bool
151 152 153 154 155 156 157 |
# File 'lib/rbs/inline/ast/annotations.rb', line 151 def complete? if name && type true else false end end |