Class: RBS::Inline::AST::Annotations::IvarType

Inherits:
Base
  • Object
show all
Defined in:
lib/rbs/inline/ast/annotations.rb

Overview

‘@rbs @foo: T` or `@rbs self.@foo: T`

Instance Attribute Summary collapse

Attributes inherited from Base

#source, #tree

Instance Method Summary collapse

Constructor Details

#initialize(tree, source) ⇒ IvarType

Returns a new instance of IvarType.



293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/rbs/inline/ast/annotations.rb', line 293

def initialize(tree, source)
  @tree = tree
  @source = source

  ivar_tree = tree.nth_tree!(1)
  @class_instance = ivar_tree.nth_token?(0).is_a?(Array)
  @name = ivar_tree.nth_token!(2).last.to_sym
  @type = ivar_tree.nth_type?(4)

  if comment = ivar_tree.nth_tree(5)
    @comment = comment.to_s
  end
end

Instance Attribute Details

#class_instanceObject (readonly)

: bool



288
289
290
# File 'lib/rbs/inline/ast/annotations.rb', line 288

def class_instance
  @class_instance
end

#commentObject (readonly)

: String?



290
291
292
# File 'lib/rbs/inline/ast/annotations.rb', line 290

def comment
  @comment
end

#nameObject (readonly)

: Symbol



284
285
286
# File 'lib/rbs/inline/ast/annotations.rb', line 284

def name
  @name
end

#typeObject (readonly)

: Types::t?



286
287
288
# File 'lib/rbs/inline/ast/annotations.rb', line 286

def type
  @type
end