Class: Parlour::Types::Intersection

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

Overview

A type which matches all of the wrapped types.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#hash, #to_type, to_type

Constructor Details

#initialize(types) ⇒ Intersection

Returns a new instance of Intersection.



140
141
142
# File 'lib/parlour/types.rb', line 140

def initialize(types)
  @types = types.map(&method(:to_type))
end

Instance Attribute Details

#typesObject (readonly)

Returns the value of attribute types.



150
151
152
# File 'lib/parlour/types.rb', line 150

def types
  @types
end

Instance Method Details

#==(other) ⇒ Object



145
146
147
# File 'lib/parlour/types.rb', line 145

def ==(other)
  Intersection === other && types == other.types
end

#describeObject



163
164
165
# File 'lib/parlour/types.rb', line 163

def describe
  "Intersection<#{types.map(&:describe).join(', ')}>"
end

#generate_rbiObject



153
154
155
# File 'lib/parlour/types.rb', line 153

def generate_rbi
  "T.all(#{types.map(&:generate_rbi).join(', ')})"
end

#generate_rbsObject



158
159
160
# File 'lib/parlour/types.rb', line 158

def generate_rbs
  "(#{types.map(&:generate_rbs).join(' & ')})"
end