Class: Types::Array

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

Instance Method Summary collapse

Methods included from Generic

#|

Constructor Details

#initialize(item_type) ⇒ Array

Returns a new instance of Array.



29
30
31
# File 'lib/types/array.rb', line 29

def initialize(item_type)
	@item_type = item_type
end

Instance Method Details

#composite?Boolean

Returns:



33
34
35
# File 'lib/types/array.rb', line 33

def composite?
	true
end

#map(values) ⇒ Object



37
38
39
# File 'lib/types/array.rb', line 37

def map(values)
	values.map{|value| @item_type.parse(value)}
end

#parse(input) ⇒ Object



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

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 Array!"
	end
end

#to_sObject



52
53
54
# File 'lib/types/array.rb', line 52

def to_s
	"Array(#{@item_type})"
end