Class: Nexter::Query::Direction
- Inherits:
-
Object
- Object
- Nexter::Query::Direction
- Defined in:
- lib/nexter/query/direction.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#compass ⇒ Object
readonly
Returns the value of attribute compass.
Instance Method Summary collapse
-
#initialize(column, compass) ⇒ Direction
constructor
A new instance of Direction.
- #slice ⇒ Object (also: #sql)
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
#column ⇒ Object (readonly)
Returns the value of attribute column.
3 4 5 |
# File 'lib/nexter/query/direction.rb', line 3 def column @column end |
#compass ⇒ Object (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
#slice ⇒ Object 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 |