Class: RBI::File

Inherits:
Object
  • Object
show all
Defined in:
lib/rbi/model.rb,
lib/rbi/printer.rb,
lib/rbi/rbs_printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strictness: nil, comments: [], &block) ⇒ File

: (?strictness: String?, ?comments: Array) ?{ (File file) -> void } -> void



148
149
150
151
152
153
# File 'lib/rbi/model.rb', line 148

def initialize(strictness: nil, comments: [], &block)
  @root = Tree.new #: Tree
  @strictness = strictness
  @comments = comments
  block&.call(self)
end

Instance Attribute Details

#commentsObject

: Array



145
146
147
# File 'lib/rbi/model.rb', line 145

def comments
  @comments
end

#rootObject

: Tree



139
140
141
# File 'lib/rbi/model.rb', line 139

def root
  @root
end

#strictnessObject

: String?



142
143
144
# File 'lib/rbi/model.rb', line 142

def strictness
  @strictness
end

Instance Method Details

#<<(node) ⇒ Object

: (Node node) -> void



156
157
158
# File 'lib/rbi/model.rb', line 156

def <<(node)
  @root << node
end

#empty?Boolean

: -> bool

Returns:

  • (Boolean)


161
162
163
# File 'lib/rbi/model.rb', line 161

def empty?
  @root.empty?
end

: (?out: (IO | StringIO), ?indent: Integer, ?print_locs: bool, ?max_line_length: Integer?) -> void



813
814
815
816
# File 'lib/rbi/printer.rb', line 813

def print(out: $stdout, indent: 0, print_locs: false, max_line_length: nil)
  p = Printer.new(out: out, indent: indent, print_locs: print_locs, max_line_length: max_line_length)
  p.visit_file(self)
end

#rbs_print(out: $stdout, indent: 0, print_locs: false) ⇒ Object

: (?out: (IO | StringIO), ?indent: Integer, ?print_locs: bool) -> void



1112
1113
1114
1115
# File 'lib/rbi/rbs_printer.rb', line 1112

def rbs_print(out: $stdout, indent: 0, print_locs: false)
  p = RBSPrinter.new(out: out, indent: indent, print_locs: print_locs)
  p.visit_file(self)
end

#rbs_string(indent: 0, print_locs: false) ⇒ Object

: (?indent: Integer, ?print_locs: bool) -> String



1118
1119
1120
1121
1122
# File 'lib/rbi/rbs_printer.rb', line 1118

def rbs_string(indent: 0, print_locs: false)
  out = StringIO.new
  rbs_print(out: out, indent: indent, print_locs: print_locs)
  out.string
end

#string(indent: 0, print_locs: false, max_line_length: nil) ⇒ Object

: (?indent: Integer, ?print_locs: bool, ?max_line_length: Integer?) -> String



819
820
821
822
823
# File 'lib/rbi/printer.rb', line 819

def string(indent: 0, print_locs: false, max_line_length: nil)
  out = StringIO.new
  print(out: out, indent: indent, print_locs: print_locs, max_line_length: max_line_length)
  out.string
end