Module: Docscribe::Types::Yard::Formatter

Defined in:
lib/docscribe/types/yard/formatter.rb

Overview

Converts YARD type AST to RBS type strings

Class Method Summary collapse

Class Method Details

.to_rbs(node) ⇒ String

Parameters:

  • node (Docscribe::Types::Yard::node?)

Returns:

  • (String)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/docscribe/types/yard/formatter.rb', line 13

def to_rbs(node) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
  return 'untyped' if node.nil?

  case node
  when Named then format_named(node)
  when Generic then format_generic(node)
  when Union then format_union(node)
  when Intersection then format_intersection(node)
  when Optional then format_optional(node)
  when Tuple then format_tuple(node)
  when HashMap then format_hash_map(node)
  when Literal then format_literal(node)
  else 'untyped'
  end
end