Class: RTurk::SearchHITs

Inherits:
Operation show all
Defined in:
lib/rturk/operations/search_hits.rb

Constant Summary

SORT_BY =
{ :title => 'Title', :reward => 'Reward', :expiration => 'Expiration', :created_at => 'CreationTime', :enumeration => 'Enumeration'}
SORT_ORDER =
{:ascending => 'Ascending', :descending => 'Descending', :asc => 'Ascending', :desc => 'Descending'}

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Operation

#check_params, create, default_params, #default_params, #initialize, #request, require_params, required_params, set_operation

Constructor Details

This class inherits a constructor from RTurk::Operation

Instance Attribute Details

- (Object) page_number

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def page_number
  @page_number
end

- (Object) page_size

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def page_size
  @page_size
end

- (Object) sort_by

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def sort_by
  @sort_by
end

- (Object) sort_order

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def sort_order
  @sort_order
end

- (Object) sort_property

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def sort_property
  @sort_property
end

Instance Method Details

- (Object) parse(xml)



18
19
20
# File 'lib/rturk/operations/search_hits.rb', line 18

def parse(xml)
  RTurk::SearchHITsResponse.new(xml)
end

- (Object) set_sort_by



32
33
34
35
36
37
# File 'lib/rturk/operations/search_hits.rb', line 32

def set_sort_by
  if @sort_by
    @sort_property = SORT_BY[@sort_by.keys.first]
    @sort_order = SORT_ORDER[@sort_by.values.first]
  end
end

- (Object) to_params



22
23
24
25
26
27
28
29
30
# File 'lib/rturk/operations/search_hits.rb', line 22

def to_params
  self.set_sort_by
  {
    'SortProperty' => self.sort_property,
    'SortDirection' => self.sort_order,
    'PageSize' => (self.page_size || 100),
    'PageNumber' => (self.page_number || 1)
  }
end