Class: Yt::Models::Caption

Inherits:
Resource
  • Object
show all
Defined in:
lib/yt/models/caption.rb

Overview

Provides methods to interact with YouTube video captions.

Constant Summary

Constants inherited from Resource

Resource::CHANNEL_PATTERNS, Resource::PLAYLIST_PATTERNS, Resource::VIDEO_PATTERNS

Instance Attribute Summary

Attributes inherited from Resource

#privacy_status

Instance Method Summary collapse

Methods inherited from Resource

#private?, #public?, #unlisted?

Instance Method Details

#download(path) ⇒ Object

Downloads a caption file.

Parameters:

  • A name for the downloaded file with caption content.

See Also:



22
23
24
25
26
27
# File 'lib/yt/models/caption.rb', line 22

def download(path)
  case io
  when StringIO then File.open(path, 'w') { |f| f.write(io.read) }
  when Tempfile then io.close; FileUtils.mv(io.path, path)
  end
end

#idString

Returns the ID used to identify the caption.

Returns:

  • the ID used to identify the caption.



11
# File 'lib/yt/models/caption.rb', line 11

has_attribute :id

#ioObject



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

def io
  @io ||= get_request(download_params).open_uri
end