123456789_123456789_123456789_123456789_123456789_

Class: YARD::Parser::RBS::Statement

Relationships & Source Files
Inherits: Object
Defined in: lib/yard/parser/rbs/statement.rb

Overview

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

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(attrs = {}) ⇒ Statement

[ GitHub ]

  
# 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

Instance Attribute Details

#attr_rbs_typeString? (readonly)

Returns:

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 47

attr_reader :attr_rbs_type

#blockArray<Statement> (readonly)

Returns:

  • (Array<Statement>)

    child statements for namespace blocks

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 37

attr_reader :block

#commentsString? (readonly)

Returns:

  • (String, nil)

    adjacent comment text (the docstring)

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 28

attr_reader :comments

#comments_hash_flagfalse (readonly)

Returns:

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 34

attr_reader :comments_hash_flag

#comments_rangeRange? (readonly)

Returns:

  • (Range, nil)

    line range of the preceding comments

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 31

attr_reader :comments_range

#lineInteger (readonly)

Returns:

  • (Integer)

    1-indexed line number of this statement

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 22

attr_reader :line

#mixin_nameString? (readonly)

Returns:

  • (String, nil)

    mixin name for :include/:extend/:prepend

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 44

attr_reader :mixin_name

#nameString (readonly)

Returns:

  • (String)

    the declaration name

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 16

attr_reader :name

#signaturesArray<String> (readonly)

Returns:

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 41

attr_reader :signatures

#sourceString (readonly)

Returns:

  • (String)

    raw source text of the statement

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 25

attr_reader :source

#superclassString? (readonly)

Returns:

  • (String, nil)

    the superclass name (for :class)

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 19

attr_reader :superclass

#typeSymbol (readonly)

Returns:

  • (Symbol)

    declaration type: :class, :module, :interface, :method_def, :attr_reader, :attr_writer, :attr_accessor, :include, :extend, :prepend, :constant, :alias

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 13

attr_reader :type

#visibilitySymbol? (readonly)

Returns:

  • (Symbol, nil)

    :class or :instance scope hint from parser

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 50

attr_reader :visibility

Instance Method Details

#showString

Returns:

  • (String)

    a textual snippet used in error messages

[ GitHub ]

  
# File 'lib/yard/parser/rbs/statement.rb', line 69

def show
  source
end