Class: Yt::Collections::Base
- Inherits:
-
Object
- Object
- Yt::Collections::Base
- Defined in:
- lib/yt/collections/base.rb
Direct Known Subclasses
Annotations, Assets, Claims, ContentOwners, Policies, References, VideoCategories, Videos
Class Method Summary collapse
Instance Method Summary collapse
- #includes(*relationships) ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#where(requirements = {}) ⇒ Object
Adds requirements to the collection in order to limit the result of List methods to only items that match the requirements.
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 16 |
# File 'lib/yt/collections/base.rb', line 13 def initialize( = {}) @parent = [:parent] @auth = [:auth] end |
Class Method Details
.of(parent) ⇒ Object
18 19 20 |
# File 'lib/yt/collections/base.rb', line 18 def self.of(parent) new parent: parent, auth: parent.auth end |
Instance Method Details
#includes(*relationships) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/yt/collections/base.rb', line 44 def includes(*relationships) self.tap do @items = [] @included_relationships = relationships end end |
#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
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 |