Class: Orbacle::UnionType

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types) ⇒ UnionType

Returns a new instance of UnionType.



5
6
7
# File 'lib/orbacle/union_type.rb', line 5

def initialize(types)
  @types_set = Set.new(types)
end

Instance Attribute Details

#types_setObject (readonly)

Returns the value of attribute types_set.



9
10
11
# File 'lib/orbacle/union_type.rb', line 9

def types_set
  @types_set
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



15
16
17
18
# File 'lib/orbacle/union_type.rb', line 15

def ==(other)
  self.class == other.class &&
    self.types_set == other.types_set
end

#bottom?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/orbacle/union_type.rb', line 36

def bottom?
  false
end

#each_possible_typeObject



28
29
30
31
32
33
34
# File 'lib/orbacle/union_type.rb', line 28

def each_possible_type
  types.each do |type|
    type.each_possible_type do |t|
      yield t
    end
  end
end

#hashObject



20
21
22
23
24
25
# File 'lib/orbacle/union_type.rb', line 20

def hash
  [
    self.class,
    self.types_set,
  ].hash ^ BIG_VALUE
end

#typesObject



11
12
13
# File 'lib/orbacle/union_type.rb', line 11

def types
  @types_set
end