Class: RBI::File
- Inherits:
-
Object
- Object
- RBI::File
- Defined in:
- lib/rbi/model.rb,
lib/rbi/printer.rb,
lib/rbi/rbs_printer.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #<<(node) ⇒ Object
- #comments? ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(strictness: nil, comments: nil, &block) ⇒ File
constructor
A new instance of File.
- #print(out: $stdout, indent: 0, print_locs: false, max_line_length: nil) ⇒ Object
- #rbs_print(out: $stdout, indent: 0, print_locs: false) ⇒ Object
- #rbs_string(indent: 0, print_locs: false) ⇒ Object
- #string(indent: 0, print_locs: false, max_line_length: nil) ⇒ Object
Constructor Details
Instance Attribute Details
#comments ⇒ Object
154 155 156 |
# File 'lib/rbi/model.rb', line 154 def comments @comments ||= [] end |
#strictness ⇒ Object
148 149 150 |
# File 'lib/rbi/model.rb', line 148 def strictness @strictness end |
Instance Method Details
#<<(node) ⇒ Object
172 173 174 |
# File 'lib/rbi/model.rb', line 172 def <<(node) @root << node end |
#comments? ⇒ Boolean
159 160 161 |
# File 'lib/rbi/model.rb', line 159 def comments? !@comments.nil? && !@comments.empty? end |
#empty? ⇒ Boolean
177 178 179 |
# File 'lib/rbi/model.rb', line 177 def empty? @root.empty? end |
#print(out: $stdout, indent: 0, print_locs: false, max_line_length: nil) ⇒ Object
859 860 861 862 |
# File 'lib/rbi/printer.rb', line 859 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
1246 1247 1248 1249 |
# File 'lib/rbi/rbs_printer.rb', line 1246 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
1252 1253 1254 1255 1256 |
# File 'lib/rbi/rbs_printer.rb', line 1252 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
865 866 867 868 869 870 871 872 |
# File 'lib/rbi/printer.rb', line 865 def string(indent: 0, print_locs: false, max_line_length: nil) # Use a mutable String buffer instead of StringIO for faster concatenation. # String#<< is ~2x faster than StringIO#print for many small writes. out = +"" p = Printer.new(out: out, indent: indent, print_locs: print_locs, max_line_length: max_line_length) p.visit_file(self) out end |