Class: RBI::File

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/rbi/model.rb,
lib/rbi/printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strictness: nil, comments: [], &block) ⇒ File

Returns a new instance of File.



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

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

Instance Attribute Details

#commentsObject

Returns the value of attribute comments.



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

def comments
  @comments
end

#rootObject

Returns the value of attribute root.



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

def root
  @root
end

#strictnessObject

Returns the value of attribute strictness.



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

def strictness
  @strictness
end

Instance Method Details

#<<(node) ⇒ Object



166
167
168
# File 'lib/rbi/model.rb', line 166

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

#empty?Boolean

Returns:

  • (Boolean)


171
172
173
# File 'lib/rbi/model.rb', line 171

def empty?
  @root.empty?
end


744
745
746
747
# File 'lib/rbi/printer.rb', line 744

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

#string(indent: 0, print_locs: false, max_line_length: nil) ⇒ Object



750
751
752
753
754
# File 'lib/rbi/printer.rb', line 750

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