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.



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

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



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

def class_instance
  @class_instance
end

#commentObject (readonly)

: String?



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

def comment
  @comment
end

#nameObject (readonly)

: Symbol



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

def name
  @name
end

#typeObject (readonly)

: Types::t?



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

def type
  @type
end