Class: RBS::Inline::AST::Annotations::Generic

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

Overview

‘# @rbs generic [type param]`

“‘rb # @rbs generic X # @rbs generic in Y # @rbs generic unchecked out Z < String – Comment here “`

Instance Attribute Summary collapse

Attributes inherited from Base

#source, #tree

Instance Method Summary collapse

Methods included from Utils

#translate_super_class, #translate_type_name, #translate_type_param

Constructor Details

#initialize(tree, source) ⇒ Generic

Returns a new instance of Generic.



571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/rbs/inline/ast/annotations.rb', line 571

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

  generic_tree = tree.nth_tree!(1)

  @type_param = translate_type_param(generic_tree.nth_tree!(1))

  if comment = generic_tree.nth_tree?(2)
    @comment = comment.to_s
  end
end

Instance Attribute Details

#commentObject (readonly)

: String?



566
567
568
# File 'lib/rbs/inline/ast/annotations.rb', line 566

def comment
  @comment
end

#type_paramObject (readonly)

TypeParam object or ‘nil` if syntax error



564
565
566
# File 'lib/rbs/inline/ast/annotations.rb', line 564

def type_param
  @type_param
end