Class: So::Eq

Inherits:
Expr show all
Defined in:
lib/spec_object.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expr

#!, #<, #==, #>, #[], #assert_time, #assert_value, #to_so_expr

Constructor Details

#initialize(a, b) ⇒ Eq

Returns a new instance of Eq.



154
155
156
157
# File 'lib/spec_object.rb', line 154

def initialize(a, b)
  @a = a
  @b = b
end

Class Method Details

.eq(a, b) ⇒ Object



159
160
161
162
163
164
165
166
167
168
# File 'lib/spec_object.rb', line 159

def self.eq(a, b)
  a = a.to_so_expr
  b = b.to_so_expr

  if a.kind_of?(Const) && b.kind_of?(Const)
    (a.value == b.value).to_so_expr
  else
    new(a, b)
  end
end

Instance Method Details

#pp(n) ⇒ Object



170
171
172
# File 'lib/spec_object.rb', line 170

def pp(n)
  "#{' '*n}(==\n#{@a.pp(n+2)}\n#{@b.pp(n+2)})"
end

#substitute(v, e) ⇒ Object



174
175
176
# File 'lib/spec_object.rb', line 174

def substitute(v, e)
  Eq.eq(@a.substitute(v, e), @b.substitute(v, e))
end