module Notu::Listing

Attributes

library[R]

Public Class Methods

new(library) click to toggle source
# File lib/notu/listing.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

Public Instance Methods

page_urls() click to toggle source
# File lib/notu/listing.rb, line 14
def page_urls
  (1..pages_count).map do |index|
    library.url(path: path, query: params.merge('page' => index))
  end
end
pages_count() click to toggle source
# File lib/notu/listing.rb, line 20
def pages_count
  document = HtmlDocument.get(library.url(path: path, query: params))
  [1, (document/'ul.pagination-list li.pagination-page').text.split(/\s+/).map(&:to_i)].flatten.compact.max
end
params() click to toggle source
# File lib/notu/listing.rb, line 25
def params
  # to be overriden
  {}
end