123456789_123456789_123456789_123456789_123456789_

Class: RBS::AST::Ruby::Annotations::BlockParamTypeAnnotation

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: RBS::AST::Ruby::Annotations::Base
Defined in: lib/rbs/ast/ruby/annotations.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(location:, prefix_location:, ampersand_location:, name_location:, colon_location:, question_location:, type_location:, type:, comment_location:) ⇒ BlockParamTypeAnnotation

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 359

def initialize(location:, prefix_location:, ampersand_location:, name_location:, colon_location:, question_location:, type_location:, type:, comment_location:)
  super(location, prefix_location)
  @ampersand_location = ampersand_location
  @name_location = name_location
  @colon_location = colon_location
  @question_location = question_location
  @type_location = type_location
  @type = type
  @comment_location = comment_location
end

Instance Attribute Details

#ampersand_location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location

#colon_location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location

#comment_location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location

#name_location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location

#optional?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 388

def optional?
  question_location ? true : false
end

#question_location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location

#required?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 392

def required?
  !optional?
end

#type (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location

#type_location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 357

attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location

Instance Method Details

#map_type_name(&block)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 370

def map_type_name(&block)
  self.class.new(
    location:,
    prefix_location:,
    ampersand_location: ampersand_location,
    name_location: name_location,
    colon_location: colon_location,
    question_location: question_location,
    type_location: type_location,
    type: type.map_type_name { yield _1 },
    comment_location: comment_location
  ) #: self
end

#name

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 384

def name
  name_location&.source&.to_sym
end

#type_fingerprint

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/annotations.rb', line 396

def type_fingerprint
  [
    "annots/block_param_type",
    name_location&.source,
    type.to_s,
    optional? ? "optional" : "required",
    comment_location&.source
  ]
end