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



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

#commentsObject

: Array



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

def comments
  @comments
end

#rootObject

: Tree



133
134
135
# File 'lib/rbi/model.rb', line 133

def root
  @root
end

#strictnessObject

: 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

Returns:

  • (Boolean)


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

def empty?
  @root.empty?
end

: (?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