zakuro 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -160
  3. data/VERSION +1 -1
  4. data/doc/condition.md +36 -0
  5. data/doc/dropped_date.md +41 -0
  6. data/doc/expection.md +108 -0
  7. data/doc/operation/csv/month.csv +100 -79
  8. data/doc/operation/operation.xlsx +0 -0
  9. data/doc/usage.md +120 -0
  10. data/doc/vanished_date.md +86 -0
  11. data/doc/version/daien.md +163 -0
  12. data/doc/version/genka.md +116 -0
  13. data/doc/version/gihou.md +172 -0
  14. data/doc/version/section/common_post_process.md +60 -0
  15. data/doc/version/section/common_pre_process.md +185 -0
  16. data/doc/version/section/const.md +45 -0
  17. data/doc/version/section/decimal.md +101 -0
  18. data/doc/version/section/lunisolar_calendar.md +55 -0
  19. data/doc/version/section/senmyou_november_1st.md +41 -0
  20. data/{lib/zakuro/version/senmyou/README.md → doc/version/senmyou.md} +15 -168
  21. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +58 -0
  22. data/lib/zakuro/calculation/monthly/first_day.rb +9 -1
  23. data/lib/zakuro/calculation/option/vanished_date/abstract_parameter.rb +40 -0
  24. data/lib/zakuro/calculation/option/vanished_date/location.rb +84 -0
  25. data/lib/zakuro/calculation/range/medieval_annual_range.rb +5 -3
  26. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +1 -0
  27. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +6 -2
  28. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +14 -0
  29. data/lib/zakuro/calculation/summary/internal/option.rb +59 -4
  30. data/lib/zakuro/context/option.rb +17 -0
  31. data/lib/zakuro/context/version_class_resolver.rb +17 -1
  32. data/lib/zakuro/operation/yaml/month.yaml +955 -281
  33. data/lib/zakuro/result/data/option/vanished_date/calculation.rb +45 -0
  34. data/lib/zakuro/result/data/option/vanished_date/option.rb +47 -0
  35. data/lib/zakuro/result/data/single_day.rb +2 -0
  36. data/lib/zakuro/version/daien/const/number.rb +2 -0
  37. data/lib/zakuro/version/daien/const/remainder.rb +7 -2
  38. data/lib/zakuro/version/daien/cycle/remainder.rb +38 -20
  39. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +2 -4
  40. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +5 -3
  41. data/lib/zakuro/version/daien/option/vanished_date/parameter.rb +33 -0
  42. data/lib/zakuro/version/daien/stella/lunar/location.rb +5 -8
  43. data/lib/zakuro/version/genka/cycle/remainder.rb +6 -2
  44. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +14 -3
  45. data/lib/zakuro/version/genka/option/vanished_date/parameter.rb +31 -0
  46. data/lib/zakuro/version/gihou/const/remainder.rb +1 -5
  47. data/lib/zakuro/version/gihou/cycle/remainder.rb +0 -26
  48. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +2 -4
  49. data/lib/zakuro/version/gihou/option/vanished_date/parameter.rb +31 -0
  50. data/lib/zakuro/version/gihou/stella/lunar/location.rb +5 -8
  51. data/lib/zakuro/version/senmyou/const/number.rb +3 -1
  52. data/lib/zakuro/version/senmyou/const/remainder.rb +3 -0
  53. data/lib/zakuro/version/senmyou/cycle/remainder.rb +17 -34
  54. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +5 -5
  55. data/lib/zakuro/version/senmyou/option/vanished_date/parameter.rb +33 -0
  56. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +6 -8
  57. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +9 -0
  58. metadata +24 -3
@@ -3,8 +3,10 @@
3
3
  require_relative '../../../context/option'
4
4
  require_relative '../../../result/data/option/dropped_date/option'
5
5
  require_relative '../../../result/data/solar_term'
6
+ require_relative '../../../result/data/option/vanished_date/option'
6
7
 
7
8
  require_relative '../../option/dropped_date/location'
9
+ require_relative '../../option/vanished_date/location'
8
10
 
9
11
  # :nodoc:
10
12
  module Zakuro
@@ -26,6 +28,8 @@ module Zakuro
26
28
  # @return [Hash<String, Result::Data::Option::AbstractOption>] オプション結果
27
29
  #
28
30
  def create(month:, day:)
31
+ # TODO: refactor
32
+
29
33
  options = {}
30
34
  context = month.context
31
35
 
@@ -38,6 +42,15 @@ module Zakuro
38
42
  options[Context::Option::DROPPED_DATE_KEY] = option
39
43
  end
40
44
 
45
+ if context.option.vanished_date?
46
+ remainder = day.remainder
47
+ average_remainder = month.first_day.average_remainder
48
+ option = vanished_date(
49
+ context: context, remainder: remainder, average_remainder: average_remainder
50
+ )
51
+ options[Context::Option::VANISHED_DATE_KEY] = option
52
+ end
53
+
41
54
  options
42
55
  end
43
56
 
@@ -53,10 +66,7 @@ module Zakuro
53
66
  # @return [Result::Data::Option::DroppedDate::Option] 没日
54
67
  #
55
68
  def dropped_date(context:, remainder:, solar_terms:)
56
- option = Result::Data::Option::DroppedDate::Option.new(
57
- matched: false,
58
- calculation: Result::Data::Option::DroppedDate::Calculation.new
59
- )
69
+ option = Result::Data::Option::DroppedDate::Option.new
60
70
 
61
71
  return option if remainder.invalid?
62
72
 
@@ -94,6 +104,51 @@ module Zakuro
94
104
  )
95
105
  )
96
106
  end
107
+
108
+ #
109
+ # 滅日を求める
110
+ #
111
+ # @param [<Type>] context <description>
112
+ # @param [<Type>] remainder <description>
113
+ # @param [<Type>] average_remainder <description>
114
+ #
115
+ # @return [<Type>] <description>
116
+ #
117
+ def vanished_date(context:, remainder:, average_remainder:)
118
+ option = Result::Data::Option::VanishedDate::Option.new
119
+
120
+ return option if average_remainder.invalid?
121
+
122
+ location = Calculation::Option::VanishedDate::Location.new(
123
+ context: context, average_remainder: average_remainder
124
+ )
125
+
126
+ return option unless location.exist?
127
+
128
+ vanished_date = location.get
129
+
130
+ return option unless remainder.day == vanished_date.day
131
+
132
+ vanished_date_option(location: location)
133
+ end
134
+
135
+ #
136
+ # 滅日オプション値を生成する
137
+ #
138
+ # @param [Calculation::Option::DroppedDate::Location] location 滅日位置
139
+ #
140
+ # @return [Result::Data::Option::DroppedDate::Option] 滅日オプション値
141
+ #
142
+ def vanished_date_option(location:)
143
+ vanished_date = location.get
144
+ Result::Data::Option::VanishedDate::Option.new(
145
+ matched: true,
146
+ calculation: Result::Data::Option::VanishedDate::Calculation.new(
147
+ remainder: vanished_date.format,
148
+ average_remainder: location.average_remainder
149
+ )
150
+ )
151
+ end
97
152
  end
98
153
  end
99
154
  end
@@ -16,6 +16,9 @@ module Zakuro
16
16
  # @return [String] 没日オプションキー名
17
17
  DROPPED_DATE_KEY = 'dropped_date'
18
18
 
19
+ # @return [String] 滅日オプションキー名
20
+ VANISHED_DATE_KEY = 'vanished_date'
21
+
19
22
  # @return [Hash<String, Object>] オプション値
20
23
  attr_reader :hash
21
24
  # @return [String] デフォルト暦名
@@ -82,6 +85,20 @@ module Zakuro
82
85
  false
83
86
  end
84
87
 
88
+ #
89
+ # 滅日か
90
+ #
91
+ # @return [True] 滅日あり
92
+ # @return [False] 滅日なし
93
+ #
94
+ def vanished_date?
95
+ value = @hash[VANISHED_DATE_KEY]
96
+
97
+ return true if value.is_a?(TrueClass)
98
+
99
+ false
100
+ end
101
+
85
102
  class << self
86
103
  #
87
104
  # 暦名を返す
@@ -4,21 +4,25 @@ require_relative '../version/genka/cycle/remainder'
4
4
  require_relative '../version/genka/cycle/solar_term'
5
5
  require_relative '../version/genka/range/annual_range'
6
6
  require_relative '../version/genka/option/dropped_date/parameter'
7
+ require_relative '../version/genka/option/vanished_date/parameter'
7
8
 
8
9
  require_relative '../version/gihou/cycle/remainder'
9
10
  require_relative '../version/gihou/cycle/solar_term'
10
11
  require_relative '../version/gihou/range/annual_range'
11
12
  require_relative '../version/gihou/option/dropped_date/parameter'
13
+ require_relative '../version/gihou/option/vanished_date/parameter'
12
14
 
13
15
  require_relative '../version/daien/cycle/remainder'
14
16
  require_relative '../version/daien/cycle/solar_term'
15
17
  require_relative '../version/daien/range/annual_range'
16
18
  require_relative '../version/daien/option/dropped_date/parameter'
19
+ require_relative '../version/daien/option/vanished_date/parameter'
17
20
 
18
21
  require_relative '../version/senmyou/cycle/remainder'
19
22
  require_relative '../version/senmyou/cycle/solar_term'
20
23
  require_relative '../version/senmyou/range/annual_range'
21
24
  require_relative '../version/senmyou/option/dropped_date/parameter'
25
+ require_relative '../version/senmyou/option/vanished_date/parameter'
22
26
 
23
27
  # :nodoc:
24
28
  module Zakuro
@@ -36,7 +40,8 @@ module Zakuro
36
40
  'remainder' => 'Zakuro::$VERSION::Cycle::Remainder',
37
41
  'solar_term' => 'Zakuro::$VERSION::Cycle::SolarTerm',
38
42
  'annual_range' => 'Zakuro::$VERSION::Range::AnnualRange',
39
- 'dropped_date_parameter' => 'Zakuro::$VERSION::Option::DroppedDate::Parameter'
43
+ 'dropped_date_parameter' => 'Zakuro::$VERSION::Option::DroppedDate::Parameter',
44
+ 'vanished_date_parameter' => 'Zakuro::$VERSION::Option::VanishedDate::Parameter'
40
45
  }.freeze
41
46
 
42
47
  #
@@ -86,6 +91,17 @@ module Zakuro
86
91
  )
87
92
  end
88
93
 
94
+ #
95
+ # 滅日引数を返す
96
+ #
97
+ # @return [Class] 没日引数クラス
98
+ #
99
+ def vanished_date_parameter
100
+ self.class.get_class(
101
+ version_name: @version_name, class_name: 'vanished_date_parameter'
102
+ )
103
+ end
104
+
89
105
  class << self
90
106
  #
91
107
  # 該当の暦のクラスを取得する