class Seaquel::Bit
Represents a small bit of an SQL expression.
Attributes
precedence[R]
str[R]
Public Class Methods
new(str, precedence)
click to toggle source
# File lib/seaquel/bit.rb, line 11 def initialize str, precedence @str = str @precedence = precedence end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
# File lib/seaquel/bit.rb, line 34 def == other return toplevel == other if other.kind_of?(String) super end
at(target_precedence)
click to toggle source
Returns a string at given target_precedence. If the precedence of this bit is lower than target_precedence, it will not be put in parenthesis.
# File lib/seaquel/bit.rb, line 19 def at target_precedence if precedence == :inf || target_precedence <= precedence @str else "(#{@str})" end end
toplevel()
click to toggle source
Returns the SQL that you would insert toplevel, meaning at a level where parens aren’t needed anymore.
# File lib/seaquel/bit.rb, line 30 def toplevel str end