Class: PostRunner::RecordListPageView

Inherits:
View
  • Object
show all
Includes:
Fit4Ruby::Converters
Defined in:
lib/postrunner/RecordListPageView.rb

Overview

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

Instance Attribute Summary

Attributes inherited from View

#doc

Instance Method Summary collapse

Methods inherited from View

#body, #to_html, #write

Constructor Details

#initialize(ffs, records, page_count, page_index) ⇒ RecordListPageView

Create a RecordListPageView object.

Parameters:

  • ffs (FitFileStore)

    Activity database

  • records (PersonalRecords)

    Database with personal records

  • page_count (Fixnum)

    Number of total pages

  • page_index (Fixnum)

    Index of the page



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# 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