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



146
147
148
149
150
151
# File 'lib/rbi/model.rb', line 146

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

Instance Attribute Details

#commentsObject

: Array



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

def comments
  @comments
end

#rootObject

: Tree



137
138
139
# File 'lib/rbi/model.rb', line 137

def root
  @root
end

#strictnessObject

: String?



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

def strictness
  @strictness
end

Instance Method Details

#<<(node) ⇒ Object

: (Node node) -> void



154
155
156
# File 'lib/rbi/model.rb', line 154

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

#empty?Boolean

: -> bool

Returns:

  • (Boolean)


159
160
161
# File 'lib/rbi/model.rb', line 159

def empty?
  @root.empty?
end

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



794
795
796
797
# File 'lib/rbi/printer.rb', line 794

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



1106
1107
1108
1109
# File 'lib/rbi/rbs_printer.rb', line 1106

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



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

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



800
801
802
803
804
# File 'lib/rbi/printer.rb', line 800

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