class YARD::Parser::RBS::Statement

Represents a single parsed declaration from an RBS file. Each Statement may have a block of child statements for namespace declarations (class, module, interface).

Attributes

attr_rbs_type[R]

@return [String, nil] RBS type annotation for attrs and constants

block[R]

@return [Array<Statement>] child statements for namespace blocks

comments[R]

@return [String, nil] adjacent comment text (the docstring)

comments_hash_flag[R]

@return [false] RBS files don’t use ## hash-flag comments

comments_range[R]

@return [Range, nil] line range of the preceding comments

line[R]

@return [Integer] 1-indexed line number of this statement

mixin_name[R]

@return [String, nil] mixin name for :include/:extend/:prepend

name[R]

@return [String] the declaration name

signatures[R]

@return [Array<String>] RBS type signature strings for :method_def

Each element is one overload (e.g. "(String name) -> Integer")
source[R]

@return [String] raw source text of the statement

superclass[R]

@return [String, nil] the superclass name (for :class)

type[R]

@return [Symbol] declaration type:

:class, :module, :interface, :method_def,
:attr_reader, :attr_writer, :attr_accessor,
:include, :extend, :prepend, :constant, :alias
visibility[R]

@return [Symbol, nil] :class or :instance scope hint from parser

Public Class Methods

new(attrs = {}) click to toggle source
# File lib/yard/parser/rbs/statement.rb, line 52
def initialize(attrs = {})
  @type              = attrs[:type]
  @name              = attrs[:name]
  @superclass        = attrs[:superclass]
  @line              = attrs[:line] || 1
  @source            = attrs[:source] || ''
  @comments          = attrs[:comments]
  @comments_range    = attrs[:comments_range]
  @comments_hash_flag = false
  @block             = attrs[:block] || []
  @signatures        = attrs[:signatures] || []
  @mixin_name        = attrs[:mixin_name]
  @attr_rbs_type     = attrs[:attr_rbs_type]
  @visibility        = attrs[:visibility]
end

Public Instance Methods

show() click to toggle source

@return [String] a textual snippet used in error messages

# File lib/yard/parser/rbs/statement.rb, line 69
def show
  source
end