Class: YouTubeG::Request::VideoSearch
- Inherits:
-
BaseSearch
- Object
- BaseSearch
- YouTubeG::Request::VideoSearch
- Defined in:
- lib/youtube_g/request/video_search.rb
Constant Summary collapse
- ONLY_EMBEDDABLE =
5
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
/-/Category1/Category2.
-
#max_results ⇒ Object
readonly
max_results.
-
#offset ⇒ Object
readonly
start-index.
-
#order_by ⇒ Object
readonly
orderby, ([relevance], viewCount).
-
#query ⇒ Object
readonly
vq.
-
#response_format ⇒ Object
readonly
alt, ([atom], rss, json).
-
#tags ⇒ Object
readonly
/-/tag1/tag2.
-
#video_format ⇒ Object
readonly
format (1=mobile devices).
Attributes inherited from BaseSearch
Instance Method Summary collapse
- #base_url ⇒ Object
-
#initialize(params = {}) ⇒ VideoSearch
constructor
A new instance of VideoSearch.
- #to_youtube_params ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ VideoSearch
Returns a new instance of VideoSearch.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/youtube_g/request/video_search.rb', line 58 def initialize(params={}) # XXX I think we want to delete the line below return if params.nil? # initialize our various member data to avoid warnings and so we'll # automatically fall back to the youtube api defaults @max_results = nil @order_by = nil @offset = nil @query = nil @response_format = nil @video_format = nil # build up the url corresponding to this request @url = base_url # http://gdata.youtube.com/feeds/videos/T7YazwP8GtY return @url << "/" << params[:video_id] if params[:video_id] @url << "/-/" if (params[:categories] || params[:tags]) @url << categories_to_params(params.delete(:categories)) if params[:categories] @url << (params.delete(:tags)) if params[:tags] params.each do |key, value| name = key.to_s instance_variable_set("@#{name}", value) if respond_to?(name) end if( params[ :only_embeddable ] ) @video_format = ONLY_EMBEDDABLE end @url << build_query_params(to_youtube_params) end |
Instance Attribute Details
#categories ⇒ Object (readonly)
/-/Category1/Category2
55 56 57 |
# File 'lib/youtube_g/request/video_search.rb', line 55 def categories @categories end |
#max_results ⇒ Object (readonly)
max_results
49 50 51 |
# File 'lib/youtube_g/request/video_search.rb', line 49 def max_results @max_results end |
#offset ⇒ Object (readonly)
start-index
51 52 53 |
# File 'lib/youtube_g/request/video_search.rb', line 51 def offset @offset end |
#order_by ⇒ Object (readonly)
orderby, ([relevance], viewCount)
50 51 52 |
# File 'lib/youtube_g/request/video_search.rb', line 50 def order_by @order_by end |
#query ⇒ Object (readonly)
vq
52 53 54 |
# File 'lib/youtube_g/request/video_search.rb', line 52 def query @query end |
#response_format ⇒ Object (readonly)
alt, ([atom], rss, json)
53 54 55 |
# File 'lib/youtube_g/request/video_search.rb', line 53 def response_format @response_format end |
#tags ⇒ Object (readonly)
/-/tag1/tag2
54 55 56 |
# File 'lib/youtube_g/request/video_search.rb', line 54 def @tags end |
#video_format ⇒ Object (readonly)
format (1=mobile devices)
56 57 58 |
# File 'lib/youtube_g/request/video_search.rb', line 56 def video_format @video_format end |
Instance Method Details
#base_url ⇒ Object
93 94 95 |
# File 'lib/youtube_g/request/video_search.rb', line 93 def base_url super << "videos" end |
#to_youtube_params ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/youtube_g/request/video_search.rb', line 97 def to_youtube_params { 'max-results' => @max_results, 'orderby' => @order_by, 'start-index' => @offset, 'vq' => @query, 'alt' => @response_format, 'format' => @video_format } end |