class TypeProf::Core::Type - typeprof: Ruby Standard Library Documentation

# class TypeProf::Core::Type

### Public Class Methods

default_param_map(genv, ty) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/type.rb, line 18
    def self.default_param_map(genv, ty)
      ty = ty.base_type(genv)
      instance_ty = ty.is_a?(Type::Instance) ? ty : Type::Instance.new(genv, ty.mod, []) # TODO: type params
      singleton_ty = ty.is_a?(Type::Instance) ? Type::Singleton.new(genv, ty.mod) : ty
      {
        "*self": Source.new(ty),
        "*instance": Source.new(instance_ty),
        "*class": Source.new(singleton_ty),
      }
    end

new(genv, *args) click to toggle source

    This new method does memoize creation of types

: (`GlobalEnv`, *untyped) -> instance

Calls superclass method

    # File typeprof-0.30.1/lib/typeprof/core/type.rb, line 5
    def self.new(genv, *args)
      genv.type_table[[self] + args] ||= super(genv, *args)
    end

strip_array(s) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/type.rb, line 14
    def self.strip_array(s)
      s.start_with?("Array[") && s.end_with?("]") ? s[6..-2] || raise : s
    end

strip_parens(s) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/type.rb, line 9
    def self.strip_parens(s)
      #s =~ /\A\((.*)\)\z/ ? $1 : s
      s.start_with?("(") && s.end_with?(")") ? s[1..-2] || raise : s
    end