Class: RBS::AST::Ruby::Annotations::InstanceVariableAnnotation

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

Overview

@rbs IVAR-NAME : TYPE annotation in leading comments

^^^^                             -- prefix_location
     ^^^^                        -- ivar_name_location
          ^                      -- colon_location
                   ^^^^^^^^^^    -- comment_location

Instance Attribute Summary collapse

Attributes inherited from Base

#location, #prefix_location

Instance Method Summary collapse

Methods inherited from Base

#buffer

Constructor Details

#initialize(location:, prefix_location:, ivar_name:, ivar_name_location:, colon_location:, type:, comment_location:) ⇒ InstanceVariableAnnotation

Returns a new instance of InstanceVariableAnnotation.



225
226
227
228
229
230
231
232
# File 'lib/rbs/ast/ruby/annotations.rb', line 225

def initialize(location:, prefix_location:, ivar_name:, ivar_name_location:, colon_location:, type:, comment_location:)
  super(location, prefix_location)
  @ivar_name = ivar_name
  @ivar_name_location = ivar_name_location
  @colon_location = colon_location
  @type = type
  @comment_location = comment_location
end

Instance Attribute Details

#colon_locationLocation (readonly)

Returns the value of attribute colon_location.

Returns:



223
224
225
# File 'lib/rbs/ast/ruby/annotations.rb', line 223

def colon_location
  @colon_location
end

#comment_locationLocation? (readonly)

Returns the value of attribute comment_location.

Returns:



223
224
225
# File 'lib/rbs/ast/ruby/annotations.rb', line 223

def comment_location
  @comment_location
end

#ivar_nameSymbol (readonly)

Returns the value of attribute ivar_name.

Returns:

  • (Symbol)


223
224
225
# File 'lib/rbs/ast/ruby/annotations.rb', line 223

def ivar_name
  @ivar_name
end

#ivar_name_locationLocation (readonly)

Returns the value of attribute ivar_name_location.

Returns:



223
224
225
# File 'lib/rbs/ast/ruby/annotations.rb', line 223

def ivar_name_location
  @ivar_name_location
end

#typeTypes::t (readonly)

Returns the value of attribute type.

Returns:

  • (Types::t)


223
224
225
# File 'lib/rbs/ast/ruby/annotations.rb', line 223

def type
  @type
end

Instance Method Details

#map_type_name {|arg0| ... } ⇒ self

Yields:

Yield Parameters:

Yield Returns:

Returns:

  • (self)


234
235
236
237
238
239
240
241
242
243
244
# File 'lib/rbs/ast/ruby/annotations.rb', line 234

def map_type_name(&block)
  self.class.new(
    location:,
    prefix_location:,
    ivar_name:,
    ivar_name_location:,
    colon_location:,
    type: type.map_type_name { yield _1 },
    comment_location:
  ) #: self
end

#type_fingerprintObject

Returns:

  • (Object)


246
247
248
249
250
251
252
253
# File 'lib/rbs/ast/ruby/annotations.rb', line 246

def type_fingerprint
  [
    "annots/instance_variable",
    ivar_name.to_s,
    type.to_s,
    comment_location&.source
  ]
end