Method: Yt::Collections::Base#where

Defined in:
lib/yt/collections/base.rb

#where(requirements = {}) ⇒ Object

Adds requirements to the collection in order to limit the result of List methods to only items that match the requirements.

Under the hood, all the requirements are passed to the YouTube API as query parameters, after transforming the keys to camel-case.

To know which requirements are available for each collection, check the documentation of the corresponding YouTube API endpoint. For instance the list of valid requirements to filter a list of videos are at developers.google.com/youtube/v3/docs/search/list

Examples:

Return the first video of a channel (no requirements):

channel.videos.first

Return the first long video of a channel by video count:

channel.videos.where(order: 'viewCount', video_duration: 'long').first


37
38
39
40
41
42
# File 'lib/yt/collections/base.rb', line 37

def where(requirements = {})
  self.tap do
    @items = []
    @where_params = requirements
  end
end