Class: Types::Tuple

Inherits:
Object
  • Object
show all
Includes:
Generic
Defined in:
lib/types/tuple.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Generic

#|

Constructor Details

#initialize(item_types) ⇒ Tuple

Returns a new instance of Tuple.



30
31
32
# File 'lib/types/tuple.rb', line 30

def initialize(item_types)
	@item_types = item_types
end

Instance Attribute Details

#item_typesObject (readonly)

Returns the value of attribute item_types.



34
35
36
# File 'lib/types/tuple.rb', line 34

def item_types
  @item_types
end

Instance Method Details

#composite?Boolean

Returns:



36
37
38
# File 'lib/types/tuple.rb', line 36

def composite?
	true
end

#parse(input) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/types/tuple.rb', line 40

def parse(input)
	case input
	when ::String
		return parse_values(parse_string(input))
	when ::Array
		return parse_values(input)
	else
		raise ArgumentError, "Cannot coerce #{input.inspect} into tuple!"
	end
end

#to_sObject



51
52
53
# File 'lib/types/tuple.rb', line 51

def to_s
	"Tuple(#{@item_types.join(', ')})"
end