Class: Parlour::Types::Tuple

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

Overview

A fixed-length array of items, each with a known type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#hash, to_type, #to_type

Constructor Details

#initialize(types) ⇒ Tuple

Returns a new instance of Tuple.



171
172
173
# File 'lib/parlour/types.rb', line 171

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

Instance Attribute Details

#typesObject (readonly)

Returns the value of attribute types.



181
182
183
# File 'lib/parlour/types.rb', line 181

def types
  @types
end

Instance Method Details

#==(other) ⇒ Object



176
177
178
# File 'lib/parlour/types.rb', line 176

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

#describeObject



194
195
196
# File 'lib/parlour/types.rb', line 194

def describe
  "[#{types.map(&:describe).join(', ')}]"
end

#generate_rbiObject



184
185
186
# File 'lib/parlour/types.rb', line 184

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

#generate_rbsObject



189
190
191
# File 'lib/parlour/types.rb', line 189

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