Module: Tigre::CommonParams

Included in:
Analysis, Sample, Url
Defined in:
lib/tigre-client/common/common_params.rb

Instance Method Summary collapse

Instance Method Details

#before_afterObject



56
57
58
# File 'lib/tigre-client/common/common_params.rb', line 56

def before_after
  "after=#{@after}&before=#{@before}"
end

#before_after_page_perObject



48
49
50
# File 'lib/tigre-client/common/common_params.rb', line 48

def before_after_page_per
  "#{before_after}&#{page_per}"
end

#common_params(params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tigre-client/common/common_params.rb', line 15

def common_params(params)
  @page = params[:page] ||= 0
  @per  = params[:per]  ||= 50
  
  if params[:after]
    if params[:after].is_a?(Time)
      @after = params[:after].to_i
    else
      @after = params[:after]
    end
  end
  if params[:before] 
    if params[:before].is_a?(Time)
      @before = params[:before].to_i
    else
      @before = params[:before]
    end
  end
end

#get_klassObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/tigre-client/common/common_params.rb', line 4

def get_klass
  case self.to_s
  when 'Tigre::Url'
    'urls'
  when 'Tigre::Sample'
    'samples'
  when 'Tigre::Analysis'
    'analyses'
  end
end

#get_logic_param(logic = nil) ⇒ Object



43
44
45
46
# File 'lib/tigre-client/common/common_params.rb', line 43

def get_logic_param(logic=nil)
  return 'any' unless logic
  logic.to_s
end

#package_array_list(list) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/tigre-client/common/common_params.rb', line 35

def package_array_list(list)
  if list.is_a?(Array)
    list.map {|m| m.strip}.join(',') 
  else
    list.split(',').map {|m| m.strip}.join(',')
  end
end

#page_perObject



52
53
54
# File 'lib/tigre-client/common/common_params.rb', line 52

def page_per
  "page=#{@page}&per=#{@per}"
end