Class: Ronin::Code::SQL::Like

Inherits:
Expr
  • Object
show all
Defined in:
lib/ronin/code/sql/like.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expr

#===, #in?, #not_in?

Constructor Details

#initialize(op, left, right, escape = nil) ⇒ Like

Returns a new instance of Like.



38
39
40
41
42
43
44
# File 'lib/ronin/code/sql/like.rb', line 38

def initialize(op,left,right,escape=nil)
  @op = op
  @left = left
  @right = right
  @escape = escape
  @negated = false
end

Instance Attribute Details

#leftObject (readonly)

Left-hand side



33
34
35
# File 'lib/ronin/code/sql/like.rb', line 33

def left
  @left
end

#opObject (readonly)

Operator



30
31
32
# File 'lib/ronin/code/sql/like.rb', line 30

def op
  @op
end

#rightObject (readonly)

Right-hand side



36
37
38
# File 'lib/ronin/code/sql/like.rb', line 36

def right
  @right
end

Instance Method Details

#emitObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ronin/code/sql/like.rb', line 54

def emit
  tokens = emit_value(@left)

  tokens += emit_token('NOT') if @negated

  tokens += emit_token(@op)
  tokens += emit_value(@right)

  if @escape
    tokens += emit_token('ESCAPE')
    tokens << @escape.to_s[0..0]
  end

  return tokens
end

#escape(str) ⇒ Object



46
47
48
# File 'lib/ronin/code/sql/like.rb', line 46

def escape(str)
  @escape = str
end

#not!Object



50
51
52
# File 'lib/ronin/code/sql/like.rb', line 50

def not!
  @negated = true
end