forked from kylejginavan/youtube_it
/
user_search.rb
39 lines (32 loc) · 1.02 KB
/
user_search.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class YouTubeG
module Request #:nodoc:
class UserSearch < BaseSearch #:nodoc:
attr_reader :max_results # max_results
attr_reader :order_by # orderby, ([relevance], viewCount, published, rating)
attr_reader :offset # start-index
def initialize(params, options={})
@max_results, @order_by, @offset = nil
@url = base_url
if params == :favorites
@url << "#{options[:user]}/favorites"
set_instance_variables(options)
elsif params[:user]
@url << "#{params[:user]}/uploads"
set_instance_variables(params)
end
@url << build_query_params(to_youtube_params)
end
private
def base_url #:nodoc:
super << "users/"
end
def to_youtube_params #:nodoc:
{
'max-results' => @max_results,
'orderby' => @order_by,
'start-index' => @offset
}
end
end
end
end