Class: YoutubeCaptions::Captions
- Inherits:
-
Object
- Object
- YoutubeCaptions::Captions
- Includes:
- HTTParty
- Defined in:
- lib/youtube-captions/captions.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(info:, lang:) ⇒ Captions
constructor
A new instance of Captions.
Constructor Details
#initialize(info:, lang:) ⇒ Captions
Returns a new instance of Captions.
9 10 11 12 |
# File 'lib/youtube-captions/captions.rb', line 9 def initialize(info:, lang:) @info = info @lang = lang end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
8 9 10 |
# File 'lib/youtube-captions/captions.rb', line 8 def info @info end |
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
8 9 10 |
# File 'lib/youtube-captions/captions.rb', line 8 def lang @lang end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/youtube-captions/captions.rb', line 14 def call if lang.nil? lang_info = default_lang_info else lang_info = search_lang_info end return raise LangNotAvailableError.new("Lang no available") unless lang_info_has_base_url?(lang_info) response = self.class.get(lang_info["baseUrl"]) = response["transcript"]["text"] () end |