Class: Tapioca::RBI::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode



16
17
18
# File 'lib/tapioca/rbi/model.rb', line 16

def initialize
  @parent_tree = nil
end

Instance Attribute Details

#parent_treeObject

Returns the value of attribute parent_tree.



13
14
15
# File 'lib/tapioca/rbi/model.rb', line 13

def parent_tree
  @parent_tree
end

Instance Method Details

#accept_printer(v) ⇒ Object



85
# File 'lib/tapioca/rbi/printer.rb', line 85

def accept_printer(v); end

#detachObject



21
22
23
24
25
26
# File 'lib/tapioca/rbi/model.rb', line 21

def detach
  tree = parent_tree
  return unless tree
  tree.nodes.delete(self)
  self.parent_tree = nil
end

#group_kindObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/tapioca/rbi/rewriters/group_nodes.rb', line 49

def group_kind
  case self
  when Include, Extend
    Group::Kind::Mixins
  when Helper
    Group::Kind::Helpers
  when TypeMember
    Group::Kind::TypeMembers
  when MixesInClassMethods
    Group::Kind::MixesInClassMethods
  when TStructField
    Group::Kind::TStructFields
  when TEnumBlock
    Group::Kind::TEnums
  when VisibilityGroup
    Group::Kind::Methods
  when Method
    if name == "initialize"
      Group::Kind::Inits
    else
      Group::Kind::Methods
    end
  when Scope, Const
    Group::Kind::Consts
  else
    raise "Unknown group for #{self}"
  end
end

#oneline?Boolean



101
102
103
# File 'lib/tapioca/rbi/printer.rb', line 101

def oneline?
  true
end


88
89
90
91
# File 'lib/tapioca/rbi/printer.rb', line 88

def print(out: $stdout, indent: 0)
  p = Printer.new(out: out, indent: indent)
  p.visit(self)
end

#string(indent: 0) ⇒ Object



94
95
96
97
98
# File 'lib/tapioca/rbi/printer.rb', line 94

def string(indent: 0)
  out = StringIO.new
  print(out: out, indent: indent)
  out.string
end