Class: Nexter::Query::Direction

Inherits:
Object
  • Object
show all
Defined in:
lib/nexter/query/direction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column, compass) ⇒ Direction

Returns a new instance of Direction.



6
7
8
9
10
# File 'lib/nexter/query/direction.rb', line 6

def initialize(column, compass)
  @column = column
  @compass = compass
  compass.direction = column[:dir]
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



3
4
5
# File 'lib/nexter/query/direction.rb', line 3

def column
  @column
end

#compassObject (readonly)

Returns the value of attribute compass.



3
4
5
# File 'lib/nexter/query/direction.rb', line 3

def compass
  @compass
end

Instance Method Details

#sliceObject Also known as: sql



12
13
14
15
16
17
18
19
20
# File 'lib/nexter/query/direction.rb', line 12

def slice
  if column[:val].present?
    delimited = "#{column[:col]} #{bracket} #{quote(column[:val])}"
    delimited.concat(" OR #{column[:col]} IS NULL") if @compass.sign == 1
    "(#{delimited})"
  elsif @compass.sign == -1
    "#{column[:col]} IS NOT NULL"
  end
end