Class: Dhallish::Types::Union
- Inherits:
-
Object
- Object
- Dhallish::Types::Union
- Defined in:
- lib/types.rb
Instance Attribute Summary collapse
-
#types ⇒ Object
types: label -> Type.
Instance Method Summary collapse
- #==(otype) ⇒ Object
-
#initialize(types) ⇒ Union
constructor
A new instance of Union.
- #to_s ⇒ Object
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
#types ⇒ Object
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_s ⇒ Object
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 |