Class: Wongi::Engine::InequalityTest

Inherits:
FilterTest show all
Defined in:
lib/wongi-engine/filter/inequality_test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FilterTest

#accept_into, #compile

Constructor Details

#initialize(x, y) ⇒ InequalityTest

Returns a new instance of InequalityTest.



7
8
9
# File 'lib/wongi-engine/filter/inequality_test.rb', line 7

def initialize x, y
  @x, @y = x, y
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



5
6
7
# File 'lib/wongi-engine/filter/inequality_test.rb', line 5

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



5
6
7
# File 'lib/wongi-engine/filter/inequality_test.rb', line 5

def y
  @y
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/wongi-engine/filter/inequality_test.rb', line 30

def == other
  super && x == other.x && y == other.y
end

#passes?(token) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wongi-engine/filter/inequality_test.rb', line 11

def passes? token

  x = if Template.variable? @x
    token[@x]
  else
    @x
  end

  y = if Template.variable? @y
    token[@y]
  else
    @y
  end

  return false if x == :_ || y == :_
  return x != y

end