Class: Types::Hash

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

Instance Method Summary collapse

Methods included from Generic

#|

Constructor Details

#initialize(key_type, value_type) ⇒ Hash

Returns a new instance of Hash.



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

def initialize(key_type, value_type)
	@key_type = key_type
	@value_type = value_type
end

Instance Method Details

#composite?Boolean

Returns:



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

def composite?
	true
end

#parse(input) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/types/hash.rb', line 38

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

#to_sObject



49
50
51
# File 'lib/types/hash.rb', line 49

def to_s
	"Hash(#{@key_type}, #{@value_type})"
end