class RMD::Base::Playlist
Attributes
errors[R]
link[R]
songs[R]
Public Class Methods
new(link)
click to toggle source
# File lib/rmd/base/playlist.rb, line 8 def initialize(link) @link = link @errors = [] @songs = [] end
Public Instance Methods
fetch()
click to toggle source
# File lib/rmd/base/playlist.rb, line 18 def fetch; end
success?()
click to toggle source
# File lib/rmd/base/playlist.rb, line 14 def success? !!songs && songs.count > 0 end
Private Instance Methods
agent()
click to toggle source
# File lib/rmd/base/playlist.rb, line 22 def agent agent ||= Mechanize.new end
calculate_progress() { |attr('href')| ... }
click to toggle source
# File lib/rmd/base/playlist.rb, line 34 def calculate_progress if song_elements != [] progress_bar = ProgressBar.create( starting_at: 0, total: song_elements.count, format: '%c / %C Songs %B %p%%' ) song_elements.each do |element| yield element.attr('href') progress_bar.increment end else @errors << 'Can not get song lists from this playlist page.' end end
page()
click to toggle source
# File lib/rmd/base/playlist.rb, line 26 def page @page ||= agent.get(link) end
song_elements()
click to toggle source
# File lib/rmd/base/playlist.rb, line 30 def song_elements @song_element ||= page.search(song_css) end