Class: AdobeConnectApi::SortDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/adobe_connect_api/sort_definition.rb

Overview

A SortDefinition can be used to sort the result server-side. It is not possible to sort according to more than two fields Example: sort = AdobeConnectAPI::SortDefinition.new sort.desc “date-created” sort.asc “sco-id”

Instance Method Summary collapse

Instance Method Details

#asc(field) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/adobe_connect_api/sort_definition.rb', line 10

def asc (field)
  if @sort1 != nil
    @sort1 = {"field" => field, "order" => "asc"}
  elsif @sort2 != nil
    @sort2 = {"field" => field, "order" => "asc"}
  end
end

#desc(field) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/adobe_connect_api/sort_definition.rb', line 18

def desc (field)
  if @sort1 != nil
    @sort1 = {"field" => field, "order" => "desc"}
  elsif @sort2 != nil
    @sort2 = {"field" => field, "order" => "desc"}
  end
end

#queryObject



26
27
28
29
30
31
32
33
34
# File 'lib/adobe_connect_api/sort_definition.rb', line 26

def query
  if (@sort1 != nil && @sort2 == nil)
    return "&sort-#{@sort1[:field]}=#{@sort1[:direction]}"
  elsif (@sort1 != nil && @sort2 != nil)
    return "&sort1-#{@sort1[:field]}=#{@sort1[:direction]}&sort2-#{@sort2[:field]}=#{@sort2[:direction]}}"
  else
    return ""
  end
end