Module: Gyunyu::Command::Export::TotalEstimate

Included in:
Format::Csv
Defined in:
lib/gyunyu/command/export/total_estimate.rb

Instance Method Summary collapse

Instance Method Details

#estimate_fieldsObject



33
34
35
36
37
# 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) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/gyunyu/command/export/total_estimate.rb', line 29

def have_estimate_fields?( fields )
  estimate_fields & fields == estimate_fields
end

#moveup_minute(sum) ⇒ Object

param

Hash sum

return

Hash



22
23
24
25
26
27
# 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) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# 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