class Argtrace::TypeUnion
Union of types (e.g. String | Integer)
Attributes
union[RW]
Public Class Methods
new()
click to toggle source
# File lib/argtrace/signature.rb, line 85 def initialize @union = [] end
Public Instance Methods
add(type)
click to toggle source
# File lib/argtrace/signature.rb, line 95 def add(type) for i in 0...@union.size if @union[i] == type # already in union return end if @union[i].superclass_of?(type) # already in union return end if type.superclass_of?(@union[i]) # remove redundant element @union[i] = nil end end @union.compact! @union << type self end
inspect()
click to toggle source
# File lib/argtrace/signature.rb, line 123 def inspect to_s end
merge_union(other_union)
click to toggle source
# File lib/argtrace/signature.rb, line 89 def merge_union(other_union) other_union.union.each do |type| self.add(type) end end
to_s()
click to toggle source
# File lib/argtrace/signature.rb, line 115 def to_s if @union.empty? "TypeUnion(None)" else "TypeUnion(" + @union.map{|x| x.to_s}.join("|") + ")" end end