Class: Dhallish::Types::Record

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types) ⇒ Record

Returns a new instance of Record.



56
57
58
# File 'lib/types.rb', line 56

def initialize(types)
	@types = types
end

Instance Attribute Details

#typesObject

Hash: keyname -> type



55
56
57
# File 'lib/types.rb', line 55

def types
  @types
end

Instance Method Details

#==(otype) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/types.rb', line 60

def ==(otype)
	if !otype.is_a? Record or @types.size != otype.types.size
		return false
	end

	@types.keys.reduce(true) { |isequal, key|
		if !isequal or !(otype.types.key? key)
			false
		else
			otype.types[key] == @types[key]
		end
	}
end

#to_sObject



74
75
76
77
78
# File 'lib/types.rb', line 74

def to_s()
	"{ #{@types.keys.map { |key|
		"#{key}: #{@types[key].to_s}"
	}.join(", ")} }"
end