Class: RBS::Types::Tuple

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/rbs/types.rb

Instance Method Summary collapse

Instance Method Details

#format(q) ⇒ Object



233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/syntax_tree/rbs/types.rb', line 233

def format(q)
  # If we don't have any sub types, we explicitly need the space in
  # between the brackets to not confuse the parser.
  if types.empty?
    q.text("[ ]")
    return
  end

  q.group do
    q.text("[")
    q.seplist(types, -> { q.text(", ") }) { |type| type.format(q) }
    q.text("]")
  end
end

#pretty_print(q) ⇒ Object



248
249
250
251
252
253
254
# File 'lib/syntax_tree/rbs/types.rb', line 248

def pretty_print(q)
  q.group(2, "(tuple", ")") do
    q.breakable
    q.text("types=")
    q.pp(types)
  end
end