Class: Ronin::Code::SQL::BinaryExpr

Inherits:
Object
  • Object
show all
Includes:
Emittable, Operators
Defined in:
lib/ronin/code/sql/binary_expr.rb

Overview

Represents a binary expression in SQL.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Emittable

#emitter, #inspect, #to_s

Methods included from Operators

#!, #!=, #%, #&, #*, #+, #+@, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #and, #as, #glob, #in, #is, #is_not, #like, #match, #not, #or, #regexp, #|, #~

Constructor Details

#initialize(left, operator, right) ⇒ BinaryExpr

Initializes the binary expression.

Parameters:

  • left (Statement, Function, BinaryExpr, Field, Literal)

    The left-hand side of the binary expression.

  • operator (Symbol)

    The binary expression's operator.

  • right (Object)

    The right-hand side of the binary expression.



64
65
66
67
68
# File 'lib/ronin/code/sql/binary_expr.rb', line 64

def initialize(left,operator,right)
  @left     = left
  @operator = operator
  @right    = right
end

Instance Attribute Details

#leftStatement, ... (readonly)

The left-hand side of the binary expression.



40
41
42
# File 'lib/ronin/code/sql/binary_expr.rb', line 40

def left
  @left
end

#operatorSymbol (readonly)

The binary expression's operator.

Returns:

  • (Symbol)


45
46
47
# File 'lib/ronin/code/sql/binary_expr.rb', line 45

def operator
  @operator
end

#rightObject (readonly)

The right-hand side of the binary expression.

Returns:

  • (Object)


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

def right
  @right
end

Instance Method Details

#to_sql(**kwargs) ⇒ String

Converts the binary expression to SQL.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Emitter#initialize.

Returns:

  • (String)

    The emitted SQL expression.



79
80
81
# File 'lib/ronin/code/sql/binary_expr.rb', line 79

def to_sql(**kwargs)
  emitter(**kwargs).emit_expression(self)
end