Class: Yt::Models::Resource

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

Direct Known Subclasses

Channel, Playlist, PlaylistItem, Video

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations::HasReports

#has_report

Methods included from Associations::HasViewerPercentages

#has_viewer_percentages

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 = {}) ⇒ Resource

Returns a new instance of Resource.



17
18
19
20
21
22
23
# File 'lib/yt/models/resource.rb', line 17

def initialize(options = {})
  @url = URL.new(options[:url]) if options[:url]
  @id = options[:id] || (@url.id if @url)
  @auth = options[:auth]
  @snippet = Snippet.new(data: options[:snippet]) if options[:snippet]
  @status = Status.new(data: options[:status]) if options[:status]
end

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



7
8
9
# File 'lib/yt/models/resource.rb', line 7

def auth
  @auth
end

Instance Method Details

#kindObject



25
26
27
# File 'lib/yt/models/resource.rb', line 25

def kind
  @url ? @url.kind.to_s : self.class.to_s.demodulize.underscore
end

#usernameObject



29
30
31
# File 'lib/yt/models/resource.rb', line 29

def username
  @url.username if @url
end