Class: Window

Inherits:
Expression show all
Defined in:
lib/eno/expressions.rb

Constant Summary collapse

S_WINDOW =
'window %s as %s'

Constants inherited from Expression

Expression::S_AND, Expression::S_DIV, Expression::S_EQ, Expression::S_GT, Expression::S_GTE, Expression::S_LT, Expression::S_LTE, Expression::S_MINUS, Expression::S_MOD, Expression::S_MUL, Expression::S_NEQ, Expression::S_OR, Expression::S_PLUS, Expression::S_TILDE

Instance Attribute Summary

Attributes inherited from Expression

#members, #props

Instance Method Summary collapse

Methods inherited from Expression

#!=, #!@, #%, #&, #*, #+, #-, #/, #<, #<=, #==, #=~, #>, #>=, #^, #as, #cast, #desc, #in, #inner_join, #join, #not_in, #not_null?, #null?, #over, #|

Constructor Details

#initialize(sym, &block) ⇒ Window

Returns a new instance of Window.



534
535
536
537
# File 'lib/eno/expressions.rb', line 534

def initialize(sym, &block)
  super(sym)
  @block = block
end

Instance Method Details

#to_sql(sql) ⇒ Object



541
542
543
544
545
546
# File 'lib/eno/expressions.rb', line 541

def to_sql(sql)
  S_WINDOW % [
    sql.quote(@members.first),
    WindowExpression.new(&@block).to_sql(sql)
  ]
end