toji 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,6 @@ module Toji
18
18
  def_delegators :@record, :acid
19
19
  def_delegators :@record, :amino_acid
20
20
  def_delegators :@record, :alcohol
21
- def_delegators :@record, :warming
22
21
  def_delegators :@record, :warmings
23
22
  def_delegators :@record, :note
24
23
 
@@ -71,7 +70,8 @@ module Toji
71
70
  if @time
72
71
  @time.strftime(format)
73
72
  else
74
- Time.at(@elapsed_time).strftime(format)
73
+ utc_offset = Time.at(0).utc_offset
74
+ Time.at(@elapsed_time - utc_offset).strftime(format)
75
75
  end
76
76
  end
77
77
 
@@ -14,12 +14,8 @@ module Toji
14
14
  :acid,
15
15
  :amino_acid,
16
16
  :alcohol,
17
- :warming,
18
- :note,
19
- ].freeze
20
-
21
- RO_KEYS = [
22
17
  :warmings,
18
+ :note,
23
19
  ].freeze
24
20
 
25
21
  attr_accessor :time
@@ -37,25 +33,19 @@ module Toji
37
33
  attr_accessor :amino_acid
38
34
  attr_accessor :alcohol
39
35
 
40
- attr_accessor :warming
36
+ attr_accessor :warmings
41
37
  attr_accessor :note
42
38
 
43
39
  def temps=(val)
44
- @temps = [val].flatten.select{|t| t}
40
+ @temps = [val].flatten.compact
45
41
  end
46
42
 
47
- def warmings
48
- result = []
49
- if @warming & WARM_DAKI
50
- result << :daki
51
- end
52
- if @warming & WARM_ANKA
53
- result << :anka
54
- end
55
- if @warming & WARM_MAT
56
- result << :mat
57
- end
58
- result
43
+ def time=(val)
44
+ @time = val&.to_time
45
+ end
46
+
47
+ def warmings=(val)
48
+ @warmings = [val].flatten.compact
59
49
  end
60
50
 
61
51
  def self.create(r)
@@ -47,21 +47,10 @@ module Toji
47
47
  }
48
48
  end
49
49
 
50
- case rice_len
51
- when 1
52
- headers += [:moto]
53
- when 2
54
- headers += [:moto, :soe]
55
- when 3
56
- headers += [:moto, :soe, :naka]
57
- when 4
58
- headers += [:moto, :soe, :naka, :tome]
59
- else
60
- headers += [:moto, :soe, :naka, :tome]
61
- (4...rice_len).each {|i|
62
- headers << "#{i}dan"
63
- }
64
- end
50
+ headers += [:moto, :soe, :naka, :tome, :yodan][0...rice_len]
51
+ (5...rice_len).each {|i|
52
+ headers << "#{i}dan"
53
+ }
65
54
 
66
55
  rows = date_rows
67
56
 
@@ -110,6 +99,23 @@ module Toji
110
99
  }
111
100
  )
112
101
  end
102
+
103
+ def self.load_hash(hash)
104
+ hash = hash.deep_symbolize_keys
105
+ products = hash[:products] || []
106
+
107
+ cal = new
108
+ products.each {|product|
109
+ cal.add(Product.create(product))
110
+ }
111
+
112
+ cal
113
+ end
114
+
115
+ def self.load_yaml_file(fname)
116
+ hash = YAML.load_file(fname)
117
+ load_hash(hash)
118
+ end
113
119
  end
114
120
  end
115
121
  end
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.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: 1.3.0
4
+ version: 1.4.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-03-22 00:00:00.000000000 Z
11
+ date: 2020-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -111,13 +111,18 @@ files:
111
111
  - bin/setup
112
112
  - example/koji_making.ipynb
113
113
  - example/koji_making.rb
114
+ - example/koji_making.yaml
114
115
  - example/koji_recipe.rb
115
116
  - example/moromi.ipynb
116
117
  - example/moromi.rb
118
+ - example/moromi.yaml
117
119
  - example/rice_recipe.rb
118
120
  - example/schedule.ipynb
121
+ - example/schedule.yaml
122
+ - example/schedule_file.ipynb
119
123
  - example/shubo.ipynb
120
124
  - example/shubo.rb
125
+ - example/shubo.yaml
121
126
  - example/three_step_mashing_recipe.rb
122
127
  - lib/toji.rb
123
128
  - lib/toji/brew.rb