Module: TreeMap::Relation

Defined in:
lib/treemap/tree_map.rb

Constant Summary collapse

LOWER =
1
FLOOR =
2
EQUAL =
3
CREATE =
4
CEILING =
5
HIGHER =
6

Class Method Summary collapse

Class Method Details

.for_order(relation, ascending) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/treemap/tree_map.rb', line 19

def self.for_order(relation, ascending)
  if ascending
    relation
  else
    case relation
    when LOWER
      HIGHER
    when FLOOR
      CEILING
    when EQUAL
      EQUAL
    when CEILING
      FLOOR
    when HIGHER
      LOWER
    else
      raise "Unknown relation: #{relation.inspect}"
    end
  end
end