class YoutubeParser::Channel

Public Instance Methods

info() click to toggle source
# File lib/youtube_parser/channel.rb, line 7
def info
  @info ||= Resource.new(collect_channel_info)
end

Private Instance Methods

about_section_info() click to toggle source
# File lib/youtube_parser/channel.rb, line 19
def about_section_info
  @about_section_info ||= section(:about).info
end
channel_url() click to toggle source
# File lib/youtube_parser/channel.rb, line 27
def channel_url
  uri = URI(client.class::BASE_URL)
  uri.path = options.channel_url

  uri.to_s
rescue URI::InvalidComponentError
  options.channel_url
end
collect_channel_info() click to toggle source
# File lib/youtube_parser/channel.rb, line 13
def collect_channel_info
  data = about_section_info.merge(video_section_info)
  data[:channel_url] = channel_url
  data.select! { |_, v| v.present? }
end
section(title) click to toggle source
# File lib/youtube_parser/channel.rb, line 36
def section(title)
  constant_name = "YoutubeParser::Channels::#{title.capitalize}Section"
  opts = { channel_url: options.channel_url, client: client }
  Object.const_get(constant_name).new(opts)
end
video_section_info() click to toggle source
# File lib/youtube_parser/channel.rb, line 23
def video_section_info
  @video_section_info ||= section(:videos).info
end