Module: Notu::Listing
- Included in:
- LovedTracks, MostPlayedTracks
- Defined in:
- lib/notu/listing.rb
Instance Attribute Summary collapse
-
#library ⇒ Object
readonly
Returns the value of attribute library.
Instance Method Summary collapse
Instance Attribute Details
#library ⇒ Object (readonly)
Returns the value of attribute library.
5 6 7 |
# File 'lib/notu/listing.rb', line 5 def library @library end |
Instance Method Details
#initialize(library) ⇒ Object
7 8 9 10 |
# File 'lib/notu/listing.rb', line 7 def initialize(library) raise ArgumentError.new("#{self.class}#library must be a library, #{library.inspect} given") unless library.is_a?(Library) @library = library end |
#page_urls ⇒ Object
12 13 14 15 16 |
# File 'lib/notu/listing.rb', line 12 def page_urls (1..pages_count).map do |index| library.url(path: path, query: params.merge('page' => index)) end end |
#pages_count ⇒ Object
18 19 20 21 |
# File 'lib/notu/listing.rb', line 18 def pages_count document = HtmlDocument.get(library.url(path: path, query: params)) [1, (document/'ul.pagination li.pages').text.split(/\s+/).map { |text| text.to_i }].flatten.compact.max end |
#params ⇒ Object
23 24 25 26 |
# File 'lib/notu/listing.rb', line 23 def params # to be overriden {} end |