Class: Dhallish::Types::Union

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types) ⇒ Union

Returns a new instance of Union.



131
132
133
# File 'lib/types.rb', line 131

def initialize(types)
	@types = types
end

Instance Attribute Details

#typesObject

types: label -> Type



130
131
132
# File 'lib/types.rb', line 130

def types
  @types
end

Instance Method Details

#==(otype) ⇒ Object



135
136
137
138
139
140
141
142
143
# File 'lib/types.rb', line 135

def ==(otype)
	if !otype.is_a? Union
		return false
	end

	@types.keys.reduce(true) { |isequal, key|
		isequal and (otype.types.include? key and @types[key] == otype.types[key])
	}
end

#to_sObject



145
146
147
148
149
# File 'lib/types.rb', line 145

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