Class: Expression

Inherits:
Object
  • Object
show all
Defined in:
lib/eno.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*members, **props) ⇒ Expression

Returns a new instance of Expression.



31
32
33
34
# File 'lib/eno.rb', line 31

def initialize(*members, **props)
  @members = members
  @props = props
end

Instance Attribute Details

#membersObject (readonly)

Returns the value of attribute members.



29
30
31
# File 'lib/eno.rb', line 29

def members
  @members
end

#propsObject (readonly)

Returns the value of attribute props.



29
30
31
# File 'lib/eno.rb', line 29

def props
  @props
end

Class Method Details

.quote(expr) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/eno.rb', line 14

def self.quote(expr)
  case expr
  when Query
    "(#{expr.to_sql.strip})"
  when Expression
    expr.to_sql
  when Symbol
    expr.to_s
  when String
    "'#{expr}'"
  else
    expr.inspect
  end
end

Instance Method Details

#!=(expr2) ⇒ Object



56
57
58
# File 'lib/eno.rb', line 56

def !=(expr2)
  Operator.new('<>', self, expr2)
end

#!@Object

not



105
106
107
# File 'lib/eno.rb', line 105

def !@
  Not.new(self)
end

#%(expr2) ⇒ Object



100
101
102
# File 'lib/eno.rb', line 100

def %(expr2)
  Operator.new('%', self, expr2)
end

#&(expr2) ⇒ Object



76
77
78
# File 'lib/eno.rb', line 76

def &(expr2)
  Operator.new('and', self, expr2)
end

#*(expr2) ⇒ Object



92
93
94
# File 'lib/eno.rb', line 92

def *(expr2)
  Operator.new('*', self, expr2)
end

#+(expr2) ⇒ Object



84
85
86
# File 'lib/eno.rb', line 84

def +(expr2)
  Operator.new('+', self, expr2)
end

#-(expr2) ⇒ Object



88
89
90
# File 'lib/eno.rb', line 88

def -(expr2)
  Operator.new('-', self, expr2)
end

#/(expr2) ⇒ Object



96
97
98
# File 'lib/eno.rb', line 96

def /(expr2)
  Operator.new('/', self, expr2)
end

#<(expr2) ⇒ Object



60
61
62
# File 'lib/eno.rb', line 60

def <(expr2)
  Operator.new('<', self, expr2)
end

#<=(expr2) ⇒ Object



68
69
70
# File 'lib/eno.rb', line 68

def <=(expr2)
  Operator.new('<=', self, expr2)
end

#==(expr2) ⇒ Object



52
53
54
# File 'lib/eno.rb', line 52

def ==(expr2)
  Operator.new('=', self, expr2)
end

#>(expr2) ⇒ Object



64
65
66
# File 'lib/eno.rb', line 64

def >(expr2)
  Operator.new('>', self, expr2)
end

#>=(expr2) ⇒ Object



72
73
74
# File 'lib/eno.rb', line 72

def >=(expr2)
  Operator.new('>=', self, expr2)
end

#as(sym = nil, &block) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/eno.rb', line 36

def as(sym = nil, &block)
  if sym
    Alias.new(self, sym)
  else
    Alias.new(self, Query.new(&block))
  end
end

#descObject



44
45
46
# File 'lib/eno.rb', line 44

def desc
  Desc.new(self)
end

#inner_join(sym, **props) ⇒ Object



121
122
123
# File 'lib/eno.rb', line 121

def inner_join(sym, **props)
  join(sym, props.merge(type: :inner))
end

#join(sym, **props) ⇒ Object



117
118
119
# File 'lib/eno.rb', line 117

def join(sym, **props)
  Join.new(self, sym, **props)
end

#not_null?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/eno.rb', line 113

def not_null?
  IsNotNull.new(self)
end

#null?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/eno.rb', line 109

def null?
  IsNull.new(self)
end

#over(sym = nil, &block) ⇒ Object



48
49
50
# File 'lib/eno.rb', line 48

def over(sym = nil, &block)
  Over.new(self, sym || WindowExpression.new(&block))
end

#|(expr2) ⇒ Object



80
81
82
# File 'lib/eno.rb', line 80

def |(expr2)
  Operator.new('or', self, expr2)
end