Class: Yoda::Typing::Types::Tuple

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/typing/types/tuple.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#reference?

Constructor Details

#initialize(*types) ⇒ Tuple

Returns a new instance of Tuple.

Parameters:

  • types (Array<Base>)


9
10
11
# File 'lib/yoda/typing/types/tuple.rb', line 9

def initialize(*types)
  @types = types
end

Instance Attribute Details

#typesArray<Base> (readonly)

Returns:



6
7
8
# File 'lib/yoda/typing/types/tuple.rb', line 6

def types
  @types
end

Instance Method Details

#to_expressionObject



13
14
15
# File 'lib/yoda/typing/types/tuple.rb', line 13

def to_expression
  Model::TypeExpressions::InstanceType.new('Array')
end

#to_type_stringObject



17
18
19
20
# File 'lib/yoda/typing/types/tuple.rb', line 17

def to_type_string
  inner = types.map(&:to_type_string)
  "(#{inner.join(', ')})"
end