class PostRunner::RecordListPageView

Generates an HTML page with all personal records for a particular sport type.

Public Class Methods

new(ffs, records, page_count, page_index) click to toggle source

Create a RecordListPageView object. @param ffs [FitFileStore] Activity database @param records [PersonalRecords] Database with personal records @param page_count [Fixnum] Number of total pages @param page_index [Fixnum] Index of the page

Calls superclass method
# File lib/postrunner/RecordListPageView.rb, line 35
def initialize(ffs, records, page_count, page_index)
  #@unit_system = ffs.store['config']['unit_system'].to_sym
  @records = records

  views = ffs.views
  views.current_page = "records-0.html"

  pages = PagingButtons.new((0..(page_count - 1)).map do |i|
    "records-#{i}.html"
  end)
  pages.current_page =
    "records-#{page_index}.html"

  @sport_name = Activity::ActivityTypes[@records.sport]
  super("#{@sport_name} Records", views, pages)

  body {
    frame_width = 800

    @doc.div({ :class => 'main' }) {
      ViewFrame.new('all_time_records', "All-time #{@sport_name} Records",
                    frame_width, @records.all_time).to_html(@doc)

      @records.yearly.sort{ |y1, y2| y2[0].to_i <=> y1[0].to_i }.
                      each do |year, record|
        next if record.empty?
        ViewFrame.new("year_#{year}_records",
                      "#{year} #{@sport_name} Records",
                      frame_width, record).to_html(@doc)
      end
    }
  }
end