Class: Yt::Models::Resource
Direct Known Subclasses
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#id ⇒ String
readonly
The ID that YouTube uses to identify each resource.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
- #kind ⇒ Object
-
#privacy_status ⇒ String
The privacy status of the resource.
-
#private? ⇒ Boolean
Whether the resource is private.
-
#public? ⇒ Boolean
Whether the resource is public.
-
#unlisted? ⇒ Boolean
Whether the resource is unlisted.
- #update(attributes = {}) ⇒ Object
- #username ⇒ Object
Methods included from Associations::HasOne
Methods included from Associations::HasMany
Methods included from Associations::HasAuthentication
Constructor Details
#initialize(options = {}) ⇒ Resource
Returns a new instance of Resource.
42 43 44 45 46 47 48 |
# File 'lib/yt/models/resource.rb', line 42 def initialize( = {}) @url = URL.new([:url]) if [:url] @id = [:id] || (@url.id if @url) @auth = [:auth] @snippet = Snippet.new(data: [:snippet]) if [:snippet] @status = Status.new(data: [:status]) if [:status] end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
9 10 11 |
# File 'lib/yt/models/resource.rb', line 9 def auth @auth end |
#id ⇒ String (readonly)
Returns the ID that YouTube uses to identify each resource.
15 |
# File 'lib/yt/models/resource.rb', line 15 has_one :id |
Instance Method Details
#kind ⇒ Object
50 51 52 |
# File 'lib/yt/models/resource.rb', line 50 def kind @url ? @url.kind.to_s : self.class.to_s.demodulize.underscore end |
#privacy_status ⇒ String
Returns the privacy status of the resource. Possible values are: ‘private’, ‘public’, ‘unlisted’.
23 |
# File 'lib/yt/models/resource.rb', line 23 delegate :privacy_status, to: :status |
#private? ⇒ Boolean
Returns whether the resource is private.
31 32 33 |
# File 'lib/yt/models/resource.rb', line 31 def private? privacy_status == 'private' end |
#public? ⇒ Boolean
Returns whether the resource is public.
26 27 28 |
# File 'lib/yt/models/resource.rb', line 26 def public? privacy_status == 'public' end |
#unlisted? ⇒ Boolean
Returns whether the resource is unlisted.
36 37 38 |
# File 'lib/yt/models/resource.rb', line 36 def unlisted? privacy_status == 'unlisted' end |
#update(attributes = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/yt/models/resource.rb', line 58 def update(attributes = {}) underscore_keys! attributes body = build_update_body attributes params = {part: body.keys.join(',')} do_update params: params, body: body.merge(id: @id) do |data| @id = data['id'] @snippet = Snippet.new data: data['snippet'] if data['snippet'] @status = Status.new data: data['status'] if data['status'] true end end |
#username ⇒ Object
54 55 56 |
# File 'lib/yt/models/resource.rb', line 54 def username @url.username if @url end |