Class: JLDrill::Gtk::StatisticsPage

Inherits:
Object
  • Object
show all
Defined in:
lib/jldrill/views/gtk/widgets/StatisticsWindow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ StatisticsPage

Returns a new instance of StatisticsPage.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 78

def initialize(view)
    @view = view
    @widget = Gtk::HBox.new()
    
    ## Layout everything in a vertical table
    counter = JLDrill::Counter.new
    rows = []
    0.upto(7) do |i|
        rows = rows.push(counter.levelString(i))
    end
    columns = [" Duration ", " Correct ", " Tried ",]
    @durationTable = StatisticsTable.new(rows, columns)
    @widget.add(@durationTable)
    rows = ["Reviewed", "Learned", " Time to review ", 
              "Time to learn", "Total Accuracy", " Learn Time % ", 
              " Curr Rate ", " Avg Rate "]
    columns = [" "]
    @rateTable = StatisticsTable.new(rows, columns)
    @widget.add(@rateTable)
end

Instance Attribute Details

#durationTableObject (readonly)

Returns the value of attribute durationTable.



76
77
78
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 76

def durationTable
  @durationTable
end

#rateTableObject (readonly)

Returns the value of attribute rateTable.



76
77
78
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 76

def rateTable
  @rateTable
end

#widgetObject (readonly)

Returns the value of attribute widget.



76
77
78
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 76

def widget
  @widget
end

Instance Method Details

#updateAccuracy(stats) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 107

def updateAccuracy(stats)
    0.upto(7) do |i|
        acc = stats.levels[i].accuracy
        if !acc.nil?
            @durationTable.values[i][1].text = acc.to_s + "% "
            @durationTable.values[i][2].text = stats.levels[i].total.to_s
        else
            @durationTable.values[i][1].text = " - "
            @durationTable.values[i][2].text = " - "
        end
    end
end

#updateDuration(counter) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 99

def updateDuration(counter)
    table = counter.table
    0.upto(6) do |i|
        @durationTable.values[i][0].text = table[i].to_s
    end
    @durationTable.values[7][0].text = table[7].to_s
end

#updateRate(stats) ⇒ Object



120
121
122
123
124
125
126
127
128
129
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 120

def updateRate(stats)
    @rateTable.values[0][0].text = stats.reviewed.to_s 
    @rateTable.values[1][0].text = stats.learned.to_s
    @rateTable.values[2][0].text = stats.reviewPace.to_s + "s "
    @rateTable.values[3][0].text = stats.learnPace.to_s + "s "
    @rateTable.values[4][0].text = stats.accuracy.to_s + "% "
    @rateTable.values[5][0].text = stats.learnTimePercent.to_s + "% "
    @rateTable.values[6][0].text = stats.currentReviewRate.to_s + "x "
    @rateTable.values[7][0].text = stats.averageReviewRate.to_s + "x "
end