Module: Toji::Product::ScheduleFactory
- Defined in:
- lib/toji/product/schedule_factory.rb
Instance Method Summary collapse
- #action_schedules ⇒ Object
- #create_action_schedule(date:, action_index:, action:) ⇒ Object
- #create_kake_schedule(date:, group_key:, step_weights:, kakes:) ⇒ Object
- #create_koji_schedule(date:, group_key:, step_weights:, kojis:) ⇒ Object
- #kake_schedules ⇒ Object
- #koji_schedules ⇒ Object
- #rice_schedules ⇒ Object
- #schedules ⇒ Object
Instance Method Details
#action_schedules ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/toji/product/schedule_factory.rb', line 76 def action_schedules recipe.actions.map.with_index {|action, i| create_action_schedule( date: base_date.next_day(action.interval_days), action_index: i, action: action, ) } end |
#create_action_schedule(date:, action_index:, action:) ⇒ Object
16 17 18 |
# File 'lib/toji/product/schedule_factory.rb', line 16 def create_action_schedule(date:, action_index:, action:) raise Error, "implement required: create_action_schedule" end |
#create_kake_schedule(date:, group_key:, step_weights:, kakes:) ⇒ Object
12 13 14 |
# File 'lib/toji/product/schedule_factory.rb', line 12 def create_kake_schedule(date:, group_key:, step_weights:, kakes:) raise Error, "implement required: create_kake_schedule" end |
#create_koji_schedule(date:, group_key:, step_weights:, kojis:) ⇒ Object
8 9 10 |
# File 'lib/toji/product/schedule_factory.rb', line 8 def create_koji_schedule(date:, group_key:, step_weights:, kojis:) raise Error, "implement required: create_koji_schedule" end |
#kake_schedules ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/toji/product/schedule_factory.rb', line 48 def kake_schedules recipe.steps.inject([]) {|result, step| step.kakes&.each {|kake| result << { step_weight: { index: step.index, subindex: step.subindex, weight: kake.weight, }, date: base_date.next_day(kake.interval_days), kake: kake, } } result }.select {|schedule| 0<schedule[:kake]&.weight.to_f }.group_by {|schedule| [schedule[:date], schedule[:kake].group_key] }.map {|(date, group_key), schedules| create_kake_schedule( date: date, group_key: "Kake:#{date.strftime('%Y%m%d')}:#{group_key}", step_weights: schedules.map {|schedule| schedule[:step_weight]}.sort_by {|x| [x[:index], x[:subindex]]}, kakes: schedules.map{|schedule| schedule[:kake]}, ) } end |
#koji_schedules ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/toji/product/schedule_factory.rb', line 20 def koji_schedules recipe.steps.inject([]) {|result, step| step.kojis&.each {|koji| result << { step_weight: { index: step.index, subindex: step.subindex, weight: koji.weight, }, date: base_date.next_day(koji.interval_days), koji: koji, } } result }.select {|schedule| 0<schedule[:koji]&.weight.to_f }.group_by {|schedule| [schedule[:date], schedule[:koji].group_key] }.map {|(date, group_key), schedules| create_koji_schedule( date: date, group_key: "Koji:#{date.strftime('%Y%m%d')}:#{group_key}", step_weights: schedules.map {|schedule| schedule[:step_weight]}.sort_by {|x| [x[:index], x[:subindex]]}, kojis: schedules.map{|schedule| schedule[:koji]}, ) } end |
#rice_schedules ⇒ Object
86 87 88 |
# File 'lib/toji/product/schedule_factory.rb', line 86 def rice_schedules koji_schedules + kake_schedules end |
#schedules ⇒ Object
90 91 92 |
# File 'lib/toji/product/schedule_factory.rb', line 90 def schedules rice_schedules + action_schedules end |