toji 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/example/calendar.ipynb +281 -21
  3. data/example/calendar_file.ipynb +37 -37
  4. data/example/example_core.rb +27 -9
  5. data/example/{kake_recipe.rb → kake_ingredient.rb} +0 -1
  6. data/example/{koji_recipe.rb → koji_ingredient.rb} +1 -2
  7. data/example/koji_making.ipynb +9 -9
  8. data/example/koji_making.yaml +1 -0
  9. data/example/koji_making_multi.ipynb +22 -57
  10. data/example/moromi.ipynb +17 -17
  11. data/example/shubo.ipynb +12 -12
  12. data/example/shubo.yaml +2 -1
  13. data/lib/toji/brew.rb +4 -2
  14. data/lib/toji/brew/base.rb +6 -26
  15. data/lib/toji/brew/builder.rb +49 -21
  16. data/lib/toji/brew/graph/bmd.rb +1 -1
  17. data/lib/toji/brew/graph/multi_progress.rb +0 -121
  18. data/lib/toji/brew/graph/progress.rb +16 -51
  19. data/lib/toji/brew/koji.rb +2 -1
  20. data/lib/toji/brew/moromi.rb +2 -1
  21. data/lib/toji/brew/shubo.rb +2 -1
  22. data/lib/toji/brew/state.rb +1 -1
  23. data/lib/toji/brew/{state_wrapper.rb → wrapped_state.rb} +6 -5
  24. data/lib/toji/ingredient/kake.rb +2 -2
  25. data/lib/toji/ingredient/kake/actual.rb +6 -7
  26. data/lib/toji/ingredient/kake/base.rb +1 -1
  27. data/lib/toji/ingredient/kake/expected.rb +0 -1
  28. data/lib/toji/ingredient/koji.rb +2 -2
  29. data/lib/toji/ingredient/koji/actual.rb +8 -9
  30. data/lib/toji/ingredient/koji/base.rb +1 -1
  31. data/lib/toji/ingredient/koji/expected.rb +0 -1
  32. data/lib/toji/ingredient/rice/actual_steamable.rb +4 -4
  33. data/lib/toji/ingredient/rice/base.rb +0 -1
  34. data/lib/toji/ingredient/rice/expected_steamable.rb +1 -3
  35. data/lib/toji/ingredient/rice_rate.rb +2 -14
  36. data/lib/toji/recipe.rb +2 -11
  37. data/lib/toji/recipe/step.rb +9 -11
  38. data/lib/toji/version.rb +1 -1
  39. metadata +5 -5
@@ -98,7 +98,7 @@ module Toji
98
98
  def self.create(val)
99
99
  if State===val
100
100
  val
101
- elsif StateWrapper==val
101
+ elsif WrappedState==val
102
102
  val.state
103
103
  #elsif Hash===val
104
104
  # #s = Class.new {
@@ -2,7 +2,7 @@ require 'forwardable'
2
2
 
3
3
  module Toji
4
4
  module Brew
5
- class StateWrapper
5
+ class WrappedState
6
6
  extend Forwardable
7
7
 
8
8
  attr_accessor :elapsed_time
@@ -21,8 +21,9 @@ module Toji
21
21
  def_delegators :@state, :warmings
22
22
  def_delegators :@state, :note
23
23
 
24
- def initialize(elapsed_time, state, brew)
25
- @elapsed_time = elapsed_time
24
+ def initialize(state, brew)
25
+ @elapsed_time = state.elapsed_time
26
+ @time = state.time
26
27
  @state = state
27
28
  @brew = brew
28
29
  end
@@ -69,8 +70,8 @@ module Toji
69
70
  def display_time(format="%m/%d %H:%M")
70
71
  if @time
71
72
  @time.strftime(format)
72
- elsif @brew.min_time
73
- time = @brew.min_time + @elapsed_time
73
+ elsif @brew.base_time
74
+ time = @brew.base_time + @elapsed_time
74
75
  time.strftime(format)
75
76
  else
76
77
  utc_offset = Time.at(0).utc_offset
@@ -9,8 +9,8 @@ module Toji
9
9
  Expected.new(raw, rice_rate: rice_rate)
10
10
  end
11
11
 
12
- def self.actual(raw, soaked, steaming_water, steamed, cooled)
13
- Actual.new(raw, soaked, steaming_water, steamed, cooled)
12
+ def self.actual(raw, soaked, steamed, cooled)
13
+ Actual.new(raw, soaked, steamed, cooled)
14
14
  end
15
15
  end
16
16
  end
@@ -5,17 +5,16 @@ module Toji
5
5
  include Base
6
6
  include Rice::ActualSteamable
7
7
 
8
- def initialize(raw, soaked, steaming_water, steamed, cooled)
9
- @raw = raw
10
- @soaked = soaked
11
- @steaming_water = steaming_water
12
- @steamed = steamed
13
- @cooled = cooled
8
+ def initialize(raw, soaked, steamed, cooled)
9
+ @raw = raw.to_f
10
+ @soaked = soaked.to_f
11
+ @steamed = steamed.to_f
12
+ @cooled = cooled.to_f
14
13
  end
15
14
 
16
15
  def *(other)
17
16
  if Integer===other || Float===other
18
- Actual.new(raw * other, soaked * other, steaming_water * other, steamed * other, cooled * other)
17
+ Actual.new(raw * other, soaked * other, steamed * other, cooled * other)
19
18
  else
20
19
  x, y = other.coerce(self)
21
20
  x * y
@@ -6,7 +6,7 @@ module Toji
6
6
 
7
7
  def +(other)
8
8
  if Base===other
9
- Actual.new(raw + other.raw, soaked + other.soaked, steaming_water + other.steaming_water, steamed + other.steamed, cooled + other.cooled)
9
+ Actual.new(raw + other.raw, soaked + other.soaked, steamed + other.steamed, cooled + other.cooled)
10
10
  else
11
11
  x, y = other.coerce(self)
12
12
  x + y
@@ -10,7 +10,6 @@ module Toji
10
10
 
11
11
  @rice_rate = rice_rate
12
12
  @soaked_rate = rice_rate.soaked_rate
13
- @before_steaming_rate = rice_rate.before_steaming_rate
14
13
  @steamed_rate = rice_rate.steamed_rate
15
14
  @cooled_rate = rice_rate.cooled_rate
16
15
  end
@@ -11,8 +11,8 @@ module Toji
11
11
  Expected.new(raw, rice_rate: rice_rate, koji_rate: koji_rate)
12
12
  end
13
13
 
14
- def self.actual(raw, soaked, steaming_water, steamed, cooled, tanekoji, dekoji)
15
- Actual.new(raw, soaked, steaming_water, steamed, cooled, tanekoji, dekoji)
14
+ def self.actual(raw, soaked, steamed, cooled, tanekoji, dekoji)
15
+ Actual.new(raw, soaked, steamed, cooled, tanekoji, dekoji)
16
16
  end
17
17
  end
18
18
  end
@@ -6,19 +6,18 @@ module Toji
6
6
  include Rice::ActualSteamable
7
7
  include ActualFermentable
8
8
 
9
- def initialize(raw, soaked, steaming_water, steamed, cooled, tanekoji, dekoji)
10
- @raw = raw
11
- @soaked = soaked
12
- @steaming_water = steaming_water
13
- @steamed = steamed
14
- @cooled = cooled
15
- @tanekoji = tanekoji
16
- @dekoji = dekoji
9
+ def initialize(raw, soaked, steamed, cooled, tanekoji, dekoji)
10
+ @raw = raw.to_f
11
+ @soaked = soaked.to_f
12
+ @steamed = steamed.to_f
13
+ @cooled = cooled.to_f
14
+ @tanekoji = tanekoji.to_f
15
+ @dekoji = dekoji.to_f
17
16
  end
18
17
 
19
18
  def *(other)
20
19
  if Integer===other || Float===other
21
- Actual.new(raw * other, soaked * other, steaming_water * other, steamed * other, cooled * other, tanekoji * other, dekoji * other)
20
+ Actual.new(raw * other, soaked * other, steamed * other, cooled * other, tanekoji * other, dekoji * other)
22
21
  else
23
22
  x, y = other.coerce(self)
24
23
  x * y
@@ -23,7 +23,7 @@ module Toji
23
23
 
24
24
  def +(other)
25
25
  if Base===other
26
- Actual.new(raw + other.raw, soaked + other.soaked, steaming_water + other.steaming_water, steamed + other.steamed, cooled + other.cooled, tanekoji + other.tanekoji, dekoji + other.dekoji)
26
+ Actual.new(raw + other.raw, soaked + other.soaked, steamed + other.steamed, cooled + other.cooled, tanekoji + other.tanekoji, dekoji + other.dekoji)
27
27
  else
28
28
  x, y = other.coerce(self)
29
29
  x + y
@@ -11,7 +11,6 @@ module Toji
11
11
 
12
12
  @rice_rate = rice_rate
13
13
  @soaked_rate = rice_rate.soaked_rate
14
- @before_steaming_rate = rice_rate.before_steaming_rate
15
14
  @steamed_rate = rice_rate.steamed_rate
16
15
  @cooled_rate = rice_rate.cooled_rate
17
16
 
@@ -10,14 +10,14 @@ module Toji
10
10
  soaked - raw
11
11
  end
12
12
 
13
- def before_steaming_rate
14
- # TODO
15
- end
16
-
17
13
  def steamed_rate
18
14
  (steamed - raw) / raw
19
15
  end
20
16
 
17
+ def steaming_water
18
+ steamed - raw
19
+ end
20
+
21
21
  def cooled_rate
22
22
  (cooled - raw) / raw
23
23
  end
@@ -21,7 +21,6 @@ module Toji
21
21
  # 蒸米吸水率は麹米及び酒母米で41〜43%、掛米は39〜40%で、吟醸造りの場合は数%低い
22
22
  #
23
23
  # 出典: 酒造教本 P48
24
- attr_reader :before_steaming_rate
25
24
  attr_reader :steamed_rate
26
25
  attr_reader :steaming_water
27
26
  attr_reader :steamed
@@ -11,9 +11,7 @@ module Toji
11
11
  end
12
12
 
13
13
  def steaming_water
14
- if before_steaming_rate
15
- raw * (before_steaming_rate - soaked_rate)
16
- end
14
+ raw * steamed_rate
17
15
  end
18
16
 
19
17
  def steamed
@@ -4,32 +4,20 @@ module Toji
4
4
  # 浸漬米吸水率
5
5
  attr_reader :soaked_rate
6
6
 
7
- # 蒸し前浸漬米吸水率
8
- # 炊飯の場合は水を追加
9
- # 蒸しの場合は一晩経って蒸発した分を削減
10
- attr_reader :before_steaming_rate
11
-
12
7
  # 蒸米吸水率
13
8
  attr_reader :steamed_rate
14
9
 
15
10
  # 放冷後蒸米吸水率
16
11
  attr_reader :cooled_rate
17
12
 
18
- def initialize(soaked_rate, before_steaming_rate, steamed_rate, cooled_rate)
13
+ def initialize(soaked_rate, steamed_rate, cooled_rate)
19
14
  @soaked_rate = soaked_rate
20
- @before_steaming_rate = before_steaming_rate
21
15
  @steamed_rate = steamed_rate
22
16
  @cooled_rate = cooled_rate
23
17
  end
24
18
 
25
- def before_steaming_rate
26
- @before_steaming_rate || begin
27
- @soaked_rate - 0.04
28
- end
29
- end
30
-
31
19
 
32
- DEFAULT = new(0.33, nil, 0.41, 0.33)
20
+ DEFAULT = new(0.33, 0.41, 0.33)
33
21
  end
34
22
  end
35
23
  end
@@ -15,9 +15,9 @@ module Toji
15
15
  }
16
16
  end
17
17
 
18
- def round(ndigit=0, half: :up)
18
+ def round(ndigit=0, mini_ndigit=nil, half: :up)
19
19
  new_steps = steps.map {|step|
20
- step.round(ndigit, half: half)
20
+ step.round(ndigit, mini_ndigit, half: half)
21
21
  }
22
22
 
23
23
  self.class.new.tap {|o|
@@ -25,15 +25,6 @@ module Toji
25
25
  }
26
26
  end
27
27
 
28
- # 内容量の累計
29
- def cumulative_weight_totals
30
- weight_total = steps.map(&:weight_total)
31
-
32
- weight_total.map.with_index {|x,i|
33
- weight_total[0..i].inject(:+)
34
- }
35
- end
36
-
37
28
  # 総米の累計
38
29
  def cumulative_rice_totals
39
30
  rice_total = steps.map(&:rice_total)
@@ -13,7 +13,7 @@ module Toji
13
13
 
14
14
  # 総米
15
15
  def rice_total
16
- kake + koji
16
+ [kake, koji].compact.map(&:to_f).sum
17
17
  end
18
18
 
19
19
  # 麹歩合
@@ -22,8 +22,7 @@ module Toji
22
22
  # なお、留め仕込みまでの麹歩合が20%を下回ると蒸米の溶解糖化に影響が出るので注意がいる
23
23
  # 出典: 酒造教本 P95
24
24
  def koji_rate
25
- ret = koji / rice_total
26
- ret.nan? ? 0.0 : ret
25
+ (koji || 0.0) / rice_total
27
26
  end
28
27
 
29
28
  # 汲水歩合
@@ -36,13 +35,12 @@ module Toji
36
35
  #
37
36
  # 出典: 酒造教本 P96
38
37
  def water_rate
39
- ret = water / rice_total
40
- ret.nan? ? 0.0 : ret
38
+ (water || 0.0) / rice_total
41
39
  end
42
40
 
43
- def round(ndigit=0, acid_ndigit=nil, half: :up)
44
- if !acid_ndigit
45
- acid_ndigit = ndigit + 3
41
+ def round(ndigit=0, mini_ndigit=nil, half: :up)
42
+ if !mini_ndigit
43
+ mini_ndigit = ndigit + 3
46
44
  end
47
45
 
48
46
  self.class.new.tap {|o|
@@ -50,9 +48,9 @@ module Toji
50
48
  o.kake = kake.round(ndigit, half: half)
51
49
  o.koji = koji.round(ndigit, half: half)
52
50
  o.water = water.round(ndigit, half: half)
53
- o.lactic_acid = lactic_acid.round(acid_ndigit, half: half)
51
+ o.lactic_acid = lactic_acid.round(mini_ndigit, half: half)
54
52
  o.alcohol = alcohol.round(ndigit, half: half)
55
- o.yeast = yeast.round(ndigit, half: half)
53
+ o.yeast = yeast.round(mini_ndigit, half: half)
56
54
  o.koji_interval_days = koji_interval_days
57
55
  o.kake_interval_days = kake_interval_days
58
56
  }
@@ -61,7 +59,7 @@ module Toji
61
59
  def +(other)
62
60
  if Step===other
63
61
  self.class.new.tap {|o|
64
- o.name = nil
62
+ o.name = name
65
63
  o.kake = kake + other.kake
66
64
  o.koji = koji + other.koji
67
65
  o.water = water + other.water
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toji
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshida Tetsuya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -113,12 +113,12 @@ files:
113
113
  - example/calendar.yaml
114
114
  - example/calendar_file.ipynb
115
115
  - example/example_core.rb
116
- - example/kake_recipe.rb
116
+ - example/kake_ingredient.rb
117
+ - example/koji_ingredient.rb
117
118
  - example/koji_making.ipynb
118
119
  - example/koji_making.rb
119
120
  - example/koji_making.yaml
120
121
  - example/koji_making_multi.ipynb
121
- - example/koji_recipe.rb
122
122
  - example/moromi.ipynb
123
123
  - example/moromi.rb
124
124
  - example/moromi.yaml
@@ -139,7 +139,7 @@ files:
139
139
  - lib/toji/brew/moromi.rb
140
140
  - lib/toji/brew/shubo.rb
141
141
  - lib/toji/brew/state.rb
142
- - lib/toji/brew/state_wrapper.rb
142
+ - lib/toji/brew/wrapped_state.rb
143
143
  - lib/toji/calendar.rb
144
144
  - lib/toji/calendar/date_column.rb
145
145
  - lib/toji/calendar/date_row.rb