module Gyunyu::Command::Export::TotalEstimate

Public Instance Methods

estimate_fields() click to toggle source
# File lib/gyunyu/command/export/total_estimate.rb, line 33
def estimate_fields
  App.constants.map(&:to_s).grep(/\AESTIMATE/).map { |e|
    App.const_get(e)
  }
end
have_estimate_fields?( fields ) click to toggle source
# File lib/gyunyu/command/export/total_estimate.rb, line 29
def have_estimate_fields?( fields )
  estimate_fields & fields == estimate_fields
end
moveup_minute( sum ) click to toggle source
param

Hash sum

return

Hash

# File lib/gyunyu/command/export/total_estimate.rb, line 22
def moveup_minute( sum )
  movedup_hour            =  sum[App::ESTIMATE_MIN] / 60
  sum[App::ESTIMATE_HOUR] += movedup_hour
  sum[App::ESTIMATE_MIN]  =  sum[App::ESTIMATE_MIN] - movedup_hour * 60
  sum
end
sum_estimate( tasks, fields ) click to toggle source
# File lib/gyunyu/command/export/total_estimate.rb, line 5
def sum_estimate( tasks, fields )
  if have_estimate_fields?( fields )
    sum = {}; estimate_fields.map { |f| sum[f] = 0 }

    tasks.each { |t|
      fields.grep(/\Aestimate/).each { |f|
        sum[f] += t[f].to_i
      }
    }
    @total_estimate = moveup_minute( sum )
  end
end