Class: Yt::Models::Resource

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

Direct Known Subclasses

Channel, Playlist, Video

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations

#has_many

Constructor Details

#initialize(options = {}) ⇒ Resource

Returns a new instance of Resource.



12
13
14
15
16
17
18
# File 'lib/yt/models/resource.rb', line 12

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



20
21
22
# File 'lib/yt/models/resource.rb', line 20

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

#usernameObject



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

def username
  @url.username if @url
end