Class: Orbacle::TypePrettyPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/orbacle/type_pretty_printer.rb

Instance Method Summary collapse

Instance Method Details

#call(type) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/orbacle/type_pretty_printer.rb', line 5

def call(type)
  case type
  when BottomType
    "unknown"
  when ClassType
    "class(#{type.name})"
  when NominalType
    type.name
  when GenericType
    pretty_parameters = type.parameters.map(&method(:call))
    "generic(#{type.name}, [#{pretty_parameters.join(", ")}])"
  when MainType
    "main"
  when UnionType
    included_types = type.types.map(&method(:call))
    "Union(#{included_types.join(" or ")})"
  end
end