Sha256: a2444b7fcbba3d76be282985fcce2d9577085db737b7b28fb8484faaaf1cb233

Contents?: true

Size: 1.59 KB

Versions: 26

Compression:

Stored size: 1.59 KB

Contents

module RBS
  module BuiltinNames
    class Name
      attr_reader :name

      def initialize(name:)
        @name = name
      end

      def to_s
        name.to_s
      end

      def instance_type(*args)
        Types::ClassInstance.new(name: name, args: args, location: nil)
      end

      def instance_type?(type)
        type.is_a?(Types::ClassInstance) && type.name == name
      end

      def singleton_type
        @singleton_type ||= Types::ClassSingleton.new(name: name, location: nil)
      end

      def singleton_type?(type)
        type.is_a?(Types::ClassSingleton) && type.name == name
      end

      def self.define(name, namespace: Namespace.root)
        new(name: TypeName.new(name: name, namespace: namespace))
      end
    end

    BasicObject = Name.new(name: TypeName.new(name: :BasicObject, namespace: Namespace.root))
    Object = Name.new(name: TypeName.new(name: :Object, namespace: Namespace.root))
    Kernel = Name.new(name: TypeName.new(name: :Kernel, namespace: Namespace.root))
    String = Name.define(:String)
    Comparable = Name.define(:Comparable)
    Enumerable = Name.define(:Enumerable)
    Class = Name.define(:Class)
    Module = Name.define(:Module)
    Array = Name.define(:Array)
    Hash = Name.define(:Hash)
    Range = Name.define(:Range)
    Enumerator = Name.define(:Enumerator)
    Set = Name.define(:Set)
    Symbol = Name.define(:Symbol)
    Integer = Name.define(:Integer)
    Float = Name.define(:Float)
    Regexp = Name.define(:Regexp)
    TrueClass = Name.define(:TrueClass)
    FalseClass = Name.define(:FalseClass)
    Numeric = Name.define(:Numeric)
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
rbs-2.6.0 lib/rbs/builtin_names.rb
rbs-2.5.1 lib/rbs/builtin_names.rb
rbs-2.5.0 lib/rbs/builtin_names.rb
rbs-2.4.0 lib/rbs/builtin_names.rb
rbs-2.3.2 lib/rbs/builtin_names.rb
rbs-2.3.1 lib/rbs/builtin_names.rb
rbs-2.3.0 lib/rbs/builtin_names.rb
rbs-2.2.2 lib/rbs/builtin_names.rb
rbs-2.2.1 lib/rbs/builtin_names.rb
rbs-2.2.0 lib/rbs/builtin_names.rb
rbs-2.1.0 lib/rbs/builtin_names.rb
rbs-2.0.0 lib/rbs/builtin_names.rb
rbs-2.0.0.pre2 lib/rbs/builtin_names.rb
rbs-2.0.0.pre1 lib/rbs/builtin_names.rb
rbs-1.8.1 lib/rbs/builtin_names.rb
rbs-1.8.0 lib/rbs/builtin_names.rb
rbs-1.7.1 lib/rbs/builtin_names.rb
rbs-1.7.0 lib/rbs/builtin_names.rb
rbs-1.7.0.beta.5 lib/rbs/builtin_names.rb
rbs-1.7.0.beta.4 lib/rbs/builtin_names.rb