Class: Warped::Sort::Value
- Inherits:
-
Object
- Object
- Warped::Sort::Value
- Defined in:
- lib/warped/api/sort/value.rb
Instance Attribute Summary collapse
-
#sort ⇒ Object
readonly
Returns the value of attribute sort.
Instance Method Summary collapse
-
#asc? ⇒ Boolean
Whether the sort is ascending.
-
#desc? ⇒ Boolean
Whether the sort is descending.
-
#direction ⇒ String
The sort direction.
-
#initialize(sort, direction) ⇒ Value
constructor
A new instance of Value.
-
#opposite_direction ⇒ String
The opposite sort direction.
Constructor Details
#initialize(sort, direction) ⇒ Value
Returns a new instance of Value.
14 15 16 17 |
# File 'lib/warped/api/sort/value.rb', line 14 def initialize(sort, direction) @sort = sort @direction = direction end |
Instance Attribute Details
#sort ⇒ Object (readonly)
Returns the value of attribute sort.
8 9 10 |
# File 'lib/warped/api/sort/value.rb', line 8 def sort @sort end |
Instance Method Details
#asc? ⇒ Boolean
Returns Whether the sort is ascending.
30 31 32 |
# File 'lib/warped/api/sort/value.rb', line 30 def asc? %w[asc asc_nulls_first asc_nulls_last].include?(direction) end |
#desc? ⇒ Boolean
Returns Whether the sort is descending.
35 36 37 |
# File 'lib/warped/api/sort/value.rb', line 35 def desc? %w[desc desc_nulls_first desc_nulls_last].include?(direction) end |
#direction ⇒ String
Returns The sort direction.
20 21 22 |
# File 'lib/warped/api/sort/value.rb', line 20 def direction sort.direction!(@direction) end |
#opposite_direction ⇒ String
Returns The opposite sort direction.
25 26 27 |
# File 'lib/warped/api/sort/value.rb', line 25 def opposite_direction sort.opposite_direction(direction) end |