lib/youtube_g/request/user_search.rb in tmm1-youtube-g-0.4.9.1 vs lib/youtube_g/request/user_search.rb in tmm1-youtube-g-0.5.0

- old
+ new

@@ -1,17 +1,42 @@ 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 - return @url << "#{options[:user]}/favorites" if params == :favorites - @url << "#{params[:user]}/uploads" if params[:user] + + if params == :favorites + @url << "#{options[:user]}/favorites" + set_instance_variables(options) + elsif params[:user] && options[:favorites] + @url << "#{params[:user]}/favorites" + set_instance_variables(params) + break + 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 \ No newline at end of file