Class: Yt::Models::Subscription

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/models/subscription.rb

Overview

Provides methods to interact with YouTube subscriptions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations::HasReports

#has_report

Methods included from Associations::HasOne

#has_one

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAuthentication

#has_authentication

Constructor Details

#initialize(options = {}) ⇒ Subscription

Returns a new instance of Subscription.



11
12
13
14
# File 'lib/yt/models/subscription.rb', line 11

def initialize(options = {})
  @id = options[:id]
  @auth = options[:auth]
end

Instance Attribute Details

#idString (readonly)

Returns the ID that uniquely identify a YouTube subscription.

Returns:

  • (String)

    the ID that uniquely identify a YouTube subscription.



9
10
11
# File 'lib/yt/models/subscription.rb', line 9

def id
  @id
end

Instance Method Details

#delete(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/yt/models/subscription.rb', line 16

def delete(options = {})
  begin
    do_delete {@id = nil}
  rescue Yt::Error => error
    ignorable_errors = error.reasons & ['subscriptionNotFound']
    raise error unless options[:ignore_errors] && ignorable_errors.any?
    @id = nil
  end
  !exists?
end

#exists?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/yt/models/subscription.rb', line 27

def exists?
  !@id.nil?
end