Class: YoutubeCaptions::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/youtube-captions/video.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:) ⇒ Video

Returns a new instance of Video.



4
5
6
# File 'lib/youtube-captions/video.rb', line 4

def initialize(id:)
  @info = YoutubeCaptions::Info.new(id: parse_youtube_id(id)).call
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



3
4
5
# File 'lib/youtube-captions/video.rb', line 3

def info
  @info
end

Instance Method Details

#available_langsObject



12
13
14
# File 'lib/youtube-captions/video.rb', line 12

def available_langs
  info.map { |json| json["languageCode"] }
end

#captions(lang: nil) ⇒ Object



8
9
10
# File 'lib/youtube-captions/video.rb', line 8

def captions(lang: nil)
  YoutubeCaptions::Captions.new(info: info, lang: lang).call
end