class Algebra::Set

Attributes

values[R]

Public Class Methods

new(values) click to toggle source
# File bin/twitter-algebra, line 99
def initialize(values)
  @values = values.uniq
end

Public Instance Methods

&(other) click to toggle source
# File bin/twitter-algebra, line 103
def &(other)
  if other.is_a?(Complement)
    Set.new(values - other.values)
  else
    Set.new(values & other.values)
  end
end
|(other) click to toggle source
# File bin/twitter-algebra, line 111
def |(other)
  if other.is_a?(Complement)
    Complement.new(other.values - values)
  else
    Set.new(values | other.values)
  end
end
~() click to toggle source
# File bin/twitter-algebra, line 119
def ~
  Complement.new(values)
end