Class: Tapioca::RBI::Scope

Inherits:
Tree show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/tapioca/rbi/model.rb,
lib/tapioca/rbi/printer.rb

Overview

Scopes

Direct Known Subclasses

Class, Module, SingletonClass

Instance Attribute Summary

Attributes inherited from Tree

#nodes

Attributes inherited from Node

#parent_tree

Instance Method Summary collapse

Methods inherited from Tree

#<<, #empty?, #group_nodes!, #initialize, #nest_non_public_methods!, #nest_singleton_methods!, #oneline?, #sort_nodes!

Methods inherited from Node

#detach, #group_kind, #initialize, #oneline?, #print, #string

Constructor Details

This class inherits a constructor from Tapioca::RBI::Tree

Instance Method Details

#accept_printer(v) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/tapioca/rbi/printer.rb', line 124

def accept_printer(v)
  previous_node = v.previous_node
  v.printn if previous_node && (!previous_node.oneline? || !oneline?)

  case self
  when Module
    v.printt("module #{name}")
  when Class
    v.printt("class #{name}")
    superclass = superclass_name
    v.print(" < #{superclass}") if superclass
  when SingletonClass
    v.printt("class << self")
  end
  if empty?
    v.printn("; end")
  else
    v.printn
    v.indent
    v.visit_all(nodes)
    v.dedent
    v.printl("end")
  end
end