Sha256: a5a4301b25f954795d84c082db41bcf80dc04e5e67fc094d8ae228d0a5b74ff0
Contents?: true
Size: 773 Bytes
Versions: 4
Compression:
Stored size: 773 Bytes
Contents
require 'insulin' require 'time' module Insulin class Week < Array def initialize date, mongo @date = date @mongo = mongo t = Time.parse @date 6.times do |i| d = (t + (i * 86400)).strftime "%F" day = Day.new d, @mongo self << day end end def average_glucose total = 0 self.each do |d| total += d.average_glucose end return total / self.size end def to_s s = "Week commencing %s" % @date s << "\n" s << "\n" self.each do |d| s << d.minimal s << "\n" end s << " " s << "Average glucose for week commencing %s: %4.1f" % [ @date, self.average_glucose ] s end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
insulin-0.0.18 | lib/insulin/week.rb |
insulin-0.0.17 | lib/insulin/week.rb |
insulin-0.0.16 | lib/insulin/week.rb |
insulin-0.0.15 | lib/insulin/week.rb |