Class: Tapioca::Compilers::Tty

Inherits:
Dsl::Compiler
  • Object
show all
Defined in:
sorbet/tapioca/compilers/tty.rb

Constant Summary collapse

ConstantType =
type_member { { fixed: T::Module[T.anything] } }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.gather_constantsEnumerable<T::Module[T.anything]>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



13
# File 'sorbet/tapioca/compilers/tty.rb', line 13

def self.gather_constants = [::Tty]

Instance Method Details

#decoratevoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'sorbet/tapioca/compilers/tty.rb', line 16

def decorate
  # `create_path` would use the overridden `Tty.to_s` (the escape codes) as the module name.
  name = constant.name
  raise ArgumentError, "Cannot generate an RBI for anonymous module #{constant.inspect}" if name.nil?

  root.create_module(name) do |mod|
    dynamic_methods = ::Tty::COLOR_CODES.keys + ::Tty::STYLE_CODES.keys + ::Tty::SPECIAL_CODES.keys

    dynamic_methods.each do |method|
      mod.create_method(method.to_s, return_type: "String", class_method: true)
    end
  end
end