class Recharge
Public Class Methods
left_today(left_total)
click to toggle source
# File Entities/Recharges.rb, line 30 def self.left_today(left_total) if (r = Recharges.search_all_).length > 0 r.sort { |a, b| a.time <=> b.time }.last.left_today(left_total) else -1 end end
Public Instance Methods
day()
click to toggle source
# File Entities/Recharges.rb, line 21 def day begin year, month, day = time.scan(/../) Date.new(2000 + year.to_i, month.to_i, day.to_i) rescue ArgumentError => e Date.today end end
left_today(left_total)
click to toggle source
# File Entities/Recharges.rb, line 15 def left_today(left_total) return -1 if days_goal.to_i <= 0 end_of_day = (days_goal.to_i - (Date.today - day) - 1) * volume.to_i / days_goal.to_i (left_total - (end_of_day < 0 ? 0 : end_of_day)).to_i end