Class: PageListFormatStrategies::WithViewCount
- Defined in:
- lib/page_list_format_strategies/with_view_count.rb
Overview
A presentation strategy that presents a list of page paths in descending order (highest number of views at the top) with their total view count.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from PageListFormatStrategies::Base
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/page_list_format_strategies/with_view_count.rb', line 9 def call presentation_strategy = proc do |page| "#{page.path} #{page.view_count} visit#{page.view_count > 1 ? 's' : ''}" end pages.sort_by { |page| -page.view_count } .map { |page| page.to_s(strategy: presentation_strategy) } end |