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
142 143 144 145 146 147 |
# File 'lib/rbi/model.rb', line 142 def initialize(strictness: nil, comments: [], &block) @root = Tree.new #: Tree @strictness = strictness @comments = comments block&.call(self) end |
Instance Attribute Details
#comments ⇒ Object
: Array
139 140 141 |
# File 'lib/rbi/model.rb', line 139 def comments @comments end |
#root ⇒ Object
: Tree
133 134 135 |
# File 'lib/rbi/model.rb', line 133 def root @root end |
#strictness ⇒ Object
: String?
136 137 138 |
# File 'lib/rbi/model.rb', line 136 def strictness @strictness end |
Instance Method Details
#<<(node) ⇒ Object
: (Node node) -> void
150 151 152 |
# File 'lib/rbi/model.rb', line 150 def <<(node) @root << node end |
#empty? ⇒ Boolean
: -> bool
155 156 157 |
# File 'lib/rbi/model.rb', line 155 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
817 818 819 820 |
# File 'lib/rbi/printer.rb', line 817 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
1210 1211 1212 1213 |
# File 'lib/rbi/rbs_printer.rb', line 1210 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
1216 1217 1218 1219 1220 |
# File 'lib/rbi/rbs_printer.rb', line 1216 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
823 824 825 826 827 |
# File 'lib/rbi/printer.rb', line 823 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 |