Class: So::Not

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expr

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

Constructor Details

#initialize(x) ⇒ Not

Returns a new instance of Not.



254
255
256
# File 'lib/spec_object.rb', line 254

def initialize(x)
  @x = x
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



258
259
260
# File 'lib/spec_object.rb', line 258

def x
  @x
end

Class Method Details

.not_(x) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
# File 'lib/spec_object.rb', line 260

def self.not_(x)
  x = x.to_so_expr

  if x.kind_of?(Const)
    (!(x.value)).to_so_expr
  elsif x.kind_of?(Not)
    x.x
  else
    new(x)
  end
end

Instance Method Details

#evaluate(calls) ⇒ Object



280
281
282
# File 'lib/spec_object.rb', line 280

def evaluate(calls)
  Not.not_(@x.evaluate(calls))
end

#pp(n) ⇒ Object



272
273
274
# File 'lib/spec_object.rb', line 272

def pp(n)
  "#{' '*n}(not\n#{@x.pp(n+2)})"
end

#substitute(v, e) ⇒ Object



276
277
278
# File 'lib/spec_object.rb', line 276

def substitute(v, e)
  Not.not_(@x.substitute(v, e))
end