class RandomYoutubeComment::YoutubeClient
Public Class Methods
random_comment_for_video(video_id)
click to toggle source
# File lib/random_youtube_comment/youtube_client.rb, line 8 def random_comment_for_video(video_id) client.comments(video_id).sample end
random_video()
click to toggle source
# File lib/random_youtube_comment/youtube_client.rb, line 12 def random_video begin video = search_for_videos.sample end while video.nil? || video.comment_count < 2 video end
Private Class Methods
client()
click to toggle source
# File lib/random_youtube_comment/youtube_client.rb, line 21 def client @client ||= YouTubeIt::Client.new end
search_for_videos()
click to toggle source
# File lib/random_youtube_comment/youtube_client.rb, line 25 def search_for_videos begin word = RandomYoutubeComment::WordnikClient.random_word videos = client.videos_by(query: word).videos end while videos.nil? || videos.length < 1 videos end