Class: Notu::LovedTracks
- Inherits:
-
Object
- Object
- Notu::LovedTracks
- Includes:
- Enumerable
- Defined in:
- lib/notu/loved_tracks.rb
Instance Attribute Summary collapse
-
#library ⇒ Object
readonly
Returns the value of attribute library.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(library) ⇒ LovedTracks
constructor
A new instance of LovedTracks.
Constructor Details
#initialize(library) ⇒ LovedTracks
Returns a new instance of LovedTracks.
9 10 11 12 |
# File 'lib/notu/loved_tracks.rb', line 9 def initialize(library) raise ArgumentError.new("#{self.class}#library must be a library, #{library.inspect} given") unless library.is_a?(Library) @library = library end |
Instance Attribute Details
#library ⇒ Object (readonly)
Returns the value of attribute library.
7 8 9 |
# File 'lib/notu/loved_tracks.rb', line 7 def library @library end |
Instance Method Details
#each(&block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/notu/loved_tracks.rb', line 14 def each(&block) return unless block_given? page_urls.each do |url| document = HtmlDocument.get(url) (document/'#lovedTracks td.subjectCell').each do |element| yield(Track.new(artist: (element/'a').first.text, title: (element/'a').last.text)) end end nil end |