Class: Parlour::Types::Class

Inherits:
Type
  • Object
show all
Defined in:
lib/parlour/types.rb

Overview

A type which represents the class of a type, rather than an instance. For example, “String” means an instance of String, but “Class(String)” means the actual String class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#hash, to_type, #to_type

Constructor Details

#initialize(type) ⇒ Class

Returns a new instance of Class.



406
407
408
# File 'lib/parlour/types.rb', line 406

def initialize(type)
  @type = to_type(type)
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



416
417
418
# File 'lib/parlour/types.rb', line 416

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



411
412
413
# File 'lib/parlour/types.rb', line 411

def ==(other)
  Class === other && type == other.type
end

#describeObject



429
430
431
# File 'lib/parlour/types.rb', line 429

def describe
  "Class<#{type.describe}>"
end

#generate_rbiObject



419
420
421
# File 'lib/parlour/types.rb', line 419

def generate_rbi
  "T.class_of(#{type.generate_rbi})"
end

#generate_rbsObject



424
425
426
# File 'lib/parlour/types.rb', line 424

def generate_rbs
  "singleton(#{type.generate_rbs})"
end