Class: YoutubeCaptions::Info
- Inherits:
-
Object
- Object
- YoutubeCaptions::Info
- Includes:
- HTTParty
- Defined in:
- lib/youtube-captions/info.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(id:) ⇒ Info
constructor
A new instance of Info.
Constructor Details
#initialize(id:) ⇒ Info
Returns a new instance of Info.
8 9 10 |
# File 'lib/youtube-captions/info.rb', line 8 def initialize(id:) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/youtube-captions/info.rb', line 7 def id @id end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/youtube-captions/info.rb', line 12 def call youtube_html = self.class.get("#{YoutubeCaptions::YOUTUBE_VIDEO_URL}#{id}") match_data = youtube_html.match(YoutubeCaptions::CAPTIONABLE_REGEX) return raise NoCaptionsAvailableError.new("No captions available") unless match_data JSON.parse(match_data[1]) end |