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
-
#comments ⇒ Object
: Array.
-
#root ⇒ Object
: Tree.
-
#strictness ⇒ Object
: String?.
Instance Method Summary collapse
-
#<<(node) ⇒ Object
: (Node node) -> void.
-
#empty? ⇒ Boolean
: -> bool.
-
#initialize(strictness: nil, comments: [], &block) ⇒ File
constructor
: (?strictness: String?, ?comments: Array) ?{ (File file) -> void } -> void.
-
#print(out: $stdout, indent: 0, print_locs: false, max_line_length: nil) ⇒ Object
: (?out: (IO | StringIO), ?indent: Integer, ?print_locs: bool, ?max_line_length: Integer?) -> void.
-
#rbs_print(out: $stdout, indent: 0, print_locs: false) ⇒ Object
: (?out: (IO | StringIO), ?indent: Integer, ?print_locs: bool) -> void.
-
#rbs_string(indent: 0, print_locs: false) ⇒ Object
: (?indent: Integer, ?print_locs: bool) -> String.
-
#string(indent: 0, print_locs: false, max_line_length: nil) ⇒ Object
: (?indent: Integer, ?print_locs: bool, ?max_line_length: Integer?) -> String.
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
#comments ⇒ Object
: Array
143 144 145 |
# File 'lib/rbi/model.rb', line 143 def comments @comments end |
#strictness ⇒ Object
: 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
159 160 161 |
# File 'lib/rbi/model.rb', line 159 def empty? @root.empty? end |
#print(out: $stdout, indent: 0, print_locs: false, max_line_length: nil) ⇒ Object
: (?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 |