Class: Symbolic::Variable

Inherits:
Object
  • Object
show all
Includes:
AST
Defined in:
lib/symbolic_ext/variable.rb

Instance Method Summary collapse

Methods included from AST

#new_ast

Instance Method Details

#!=(obj) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/symbolic_ext/variable.rb', line 30

def !=(obj)
  if obj.is_a?(Variable) || obj.is_a?(Numeric)
    return object_id == obj.object_id ? false : nil
  end

  return !self if obj.equal?(true)
  return self if obj.equal?(false)
  return false if obj.equal?(self)
  nil
end

#<(obj) ⇒ Object



22
23
24
# File 'lib/symbolic_ext/variable.rb', line 22

def <(obj)
  eql?(obj) ? false : nil
end

#<=(obj) ⇒ Object



57
58
59
# File 'lib/symbolic_ext/variable.rb', line 57

def <=(obj)
  object_id == obj.object_id ? true : nil
end

#==(obj) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/symbolic_ext/variable.rb', line 41

def ==(obj)
  if obj.is_a?(Variable) || obj.is_a?(Numeric)
    result = object_id == obj.object_id ? true : nil
    return result
  end

  return !self if obj.equal?(false)
  return self if obj.equal?(true)
  return true if obj.equal?(self)
  nil
end

#>(obj) ⇒ Object



26
27
28
# File 'lib/symbolic_ext/variable.rb', line 26

def >(obj)
  eql?(obj) ? false : nil
end

#>=(obj) ⇒ Object



53
54
55
# File 'lib/symbolic_ext/variable.rb', line 53

def >=(obj)
  object_id == obj.object_id ? true : nil
end

#and(obj) ⇒ Object



10
11
12
13
14
# File 'lib/symbolic_ext/variable.rb', line 10

def and(obj)
  return self if obj.equal?(true) || obj.equal?(self)
  return false if obj.equal?(false)
  nil
end

#or(obj) ⇒ Object



16
17
18
19
20
# File 'lib/symbolic_ext/variable.rb', line 16

def or(obj)
  return self if obj.equal?(false) || obj.equal?(self)
  return true if obj.equal?(true)
  nil
end