Module: Medic::Sort

Included in:
SampleQueryBuilder
Defined in:
lib/medic/sort.rb

Constant Summary collapse

SORT_IDENTIFIERS =
{
  start_date: HKSampleSortIdentifierStartDate,
  end_date: HKSampleSortIdentifierEndDate
}

Instance Method Summary collapse

Instance Method Details

#sort_descriptors(symbols, ascending = true) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/medic/sort.rb', line 9

def sort_descriptors(symbols, ascending=true)
  Array(symbols).map do |sym|
    if sym.is_a? NSSortDescriptor
      sym
    else
      NSSortDescriptor.alloc.initWithKey(sort_identifier(sym), ascending: ascending)
    end
  end
end

#sort_identifier(sort_id) ⇒ Object



19
20
21
# File 'lib/medic/sort.rb', line 19

def sort_identifier(sort_id)
  sort_id.is_a?(Symbol) ? SORT_IDENTIFIERS[sort_id] : sort_id
end