zakuro 0.6.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +3 -0
  3. data/README.md +46 -17
  4. data/VERSION +1 -1
  5. data/doc/dropped_date.md +93 -0
  6. data/doc/error.md +45 -0
  7. data/doc/operation/transfer.rb +8 -8
  8. data/lib/zakuro/calculation/base/day.rb +52 -0
  9. data/lib/zakuro/calculation/base/gengou.rb +49 -3
  10. data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
  11. data/lib/zakuro/calculation/base/operated_year.rb +26 -24
  12. data/lib/zakuro/calculation/base/year.rb +7 -7
  13. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
  14. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
  15. data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
  16. data/lib/zakuro/calculation/era/gengou/{scroll.rb → abstract_scroll.rb} +44 -37
  17. data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
  18. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
  19. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
  20. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/{list.rb → abstract_list.rb} +50 -64
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve/{range.rb → abstract_range.rb} +73 -50
  23. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
  24. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
  25. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +156 -0
  26. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
  27. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +73 -0
  28. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +23 -22
  29. data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
  30. data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
  31. data/lib/zakuro/calculation/era/version/version.rb +12 -10
  32. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
  33. data/lib/zakuro/calculation/monthly/const.rb +18 -0
  34. data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
  35. data/lib/zakuro/calculation/monthly/month.rb +55 -16
  36. data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
  37. data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
  38. data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
  39. data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
  40. data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
  41. data/lib/zakuro/calculation/range/{full_range.rb → abstract_full_range.rb} +45 -29
  42. data/lib/zakuro/calculation/range/abstract_operation_range.rb +193 -0
  43. data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
  44. data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
  45. data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
  46. data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
  47. data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
  48. data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
  49. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
  50. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
  51. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
  52. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
  53. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
  54. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
  55. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
  56. data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
  57. data/lib/zakuro/calculation/{specifier → summary}/internal/month.rb +33 -12
  58. data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
  59. data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
  60. data/lib/zakuro/calculation/summary/japan/range.rb +179 -0
  61. data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
  62. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +98 -0
  63. data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
  64. data/lib/zakuro/calculation/summary/western/range.rb +127 -0
  65. data/lib/zakuro/calculation/summary/western/single.rb +115 -0
  66. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +173 -0
  67. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +100 -0
  68. data/lib/zakuro/calculation/type/old_float.rb +2 -2
  69. data/lib/zakuro/calculation/type/optional.rb +46 -0
  70. data/lib/zakuro/condition.rb +143 -94
  71. data/lib/zakuro/context/context.rb +44 -0
  72. data/lib/zakuro/context/option.rb +119 -0
  73. data/lib/zakuro/context/version_class_resolver.rb +112 -0
  74. data/lib/zakuro/era/japan/calendar.rb +35 -33
  75. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +93 -74
  76. data/lib/zakuro/era/japan/gengou/alignment/division.rb +135 -133
  77. data/lib/zakuro/era/japan/gengou/alignment/line.rb +143 -122
  78. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +177 -168
  79. data/lib/zakuro/era/japan/gengou/alignment.rb +40 -25
  80. data/lib/zakuro/era/japan/gengou/resource/parser.rb +199 -181
  81. data/lib/zakuro/era/japan/gengou/resource/type.rb +243 -234
  82. data/lib/zakuro/era/japan/gengou/resource/validator.rb +257 -254
  83. data/lib/zakuro/era/japan/gengou/resource.rb +23 -22
  84. data/lib/zakuro/era/japan/gengou.rb +28 -41
  85. data/lib/zakuro/era/japan/version.rb +18 -16
  86. data/lib/zakuro/era/western/calendar.rb +104 -88
  87. data/lib/zakuro/exception/case/pattern.rb +71 -0
  88. data/lib/zakuro/exception/case/preset.rb +51 -0
  89. data/lib/zakuro/exception/case/template.rb +48 -0
  90. data/lib/zakuro/exception/cause.rb +28 -0
  91. data/lib/zakuro/exception/exception.rb +39 -0
  92. data/lib/zakuro/exception/zakuro_error.rb +46 -0
  93. data/lib/zakuro/gateway/locale/date.rb +127 -0
  94. data/lib/zakuro/gateway/locale/range.rb +67 -0
  95. data/lib/zakuro/gateway/range.rb +99 -0
  96. data/lib/zakuro/gateway/single.rb +81 -0
  97. data/lib/zakuro/merchant.rb +67 -33
  98. data/lib/zakuro/operation/month/parser.rb +252 -249
  99. data/lib/zakuro/operation/month/type.rb +44 -35
  100. data/lib/zakuro/operation/month/validator.rb +182 -178
  101. data/lib/zakuro/operation/operation.rb +38 -36
  102. data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
  103. data/lib/zakuro/output/logger.rb +17 -3
  104. data/lib/zakuro/output/response.rb +107 -141
  105. data/lib/zakuro/result/data/day.rb +43 -0
  106. data/lib/zakuro/result/data/gengou.rb +35 -0
  107. data/lib/zakuro/result/data/month.rb +63 -0
  108. data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
  109. data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
  110. data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
  111. data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
  112. data/lib/zakuro/result/data/single_day.rb +56 -0
  113. data/lib/zakuro/result/data/solar_term.rb +35 -0
  114. data/lib/zakuro/result/data/year.rb +45 -0
  115. data/lib/zakuro/result/operation/month/annotation.rb +40 -0
  116. data/lib/zakuro/result/operation/month/history.rb +54 -0
  117. data/lib/zakuro/result/operation/month.rb +31 -0
  118. data/lib/zakuro/result/operation.rb +22 -97
  119. data/lib/zakuro/result/result.rb +6 -4
  120. data/lib/zakuro/tools/stringifier.rb +67 -42
  121. data/lib/zakuro/tools/typeconv.rb +17 -15
  122. data/lib/zakuro/tools/typeof.rb +15 -13
  123. data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
  124. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
  125. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
  126. data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
  127. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
  128. data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
  129. data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
  130. data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
  131. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
  132. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
  133. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
  134. data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
  135. data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
  136. data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
  137. data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
  138. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
  139. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
  140. data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
  141. data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
  142. data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
  143. data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
  144. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
  145. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
  146. data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
  147. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
  148. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
  149. data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
  150. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
  151. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
  152. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
  153. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
  154. data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
  155. data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
  156. data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
  157. data/lib/zakuro/version/senmyou/const/remainder.rb +5 -0
  158. data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
  159. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
  160. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
  161. data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
  162. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
  163. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
  164. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
  165. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
  166. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
  167. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
  168. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
  169. data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
  170. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
  171. data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
  172. metadata +68 -16
  173. data/lib/zakuro/calculation/range/operated_range.rb +0 -193
  174. data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -220
  175. data/lib/zakuro/calculation/specifier/multiple_day.rb +0 -162
  176. data/lib/zakuro/calculation/specifier/single_day.rb +0 -87
  177. data/lib/zakuro/calculation/summary/range.rb +0 -120
  178. data/lib/zakuro/calculation/summary/single.rb +0 -110
  179. data/lib/zakuro/result/data.rb +0 -187
  180. data/lib/zakuro/version/context.rb +0 -44
  181. data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -20,122 +20,124 @@ module Zakuro
20
20
  EMPTY_STRING = '-'
21
21
  BOOLEANS = %w[true false].freeze
22
22
 
23
- #
24
- # 有効文字列か
25
- #
26
- # @param [String] str 対象文字列
27
- #
28
- # @return [True] 有効
29
- # @return [False] 無効
30
- #
31
- def self.string?(str: '')
32
- return false if str == ''
23
+ class << self
24
+ #
25
+ # 有効文字列か
26
+ #
27
+ # @param [String] str 対象文字列
28
+ #
29
+ # @return [True] 有効
30
+ # @return [False] 無効
31
+ #
32
+ def string?(str: '')
33
+ return false if str == ''
33
34
 
34
- return false unless str
35
+ return false unless str
35
36
 
36
- str.is_a?(String)
37
- end
37
+ str.is_a?(String)
38
+ end
38
39
 
39
- #
40
- # 有効文字列(空文字許容)か
41
- #
42
- # @param [String] str 対象文字列
43
- #
44
- # @return [True] 有効
45
- # @return [False] 無効
46
- #
47
- def self.empiable_string?(str: '')
48
- return false unless str
40
+ #
41
+ # 有効文字列(空文字許容)か
42
+ #
43
+ # @param [String] str 対象文字列
44
+ #
45
+ # @return [True] 有効
46
+ # @return [False] 無効
47
+ #
48
+ def empiable_string?(str: '')
49
+ return false unless str
49
50
 
50
- str.is_a?(String)
51
- end
51
+ str.is_a?(String)
52
+ end
52
53
 
53
- #
54
- # 正数か
55
- #
56
- # @param [String] str 対象文字列
57
- #
58
- # @return [True] 正数
59
- # @return [False] 負数
60
- #
61
- def self.positive?(str: '')
62
- return true if str == EMPTY_STRING
54
+ #
55
+ # 正数か
56
+ #
57
+ # @param [String] str 対象文字列
58
+ #
59
+ # @return [True] 正数
60
+ # @return [False] 負数
61
+ #
62
+ def positive?(str: '')
63
+ return true if str == EMPTY_STRING
63
64
 
64
- return false unless str
65
+ return false unless str
65
66
 
66
- /^[0-9]+$/.match?(str)
67
- end
67
+ /^[0-9]+$/.match?(str)
68
+ end
68
69
 
69
- #
70
- # 数値か
71
- #
72
- # @param [String] str 対象文字列
73
- #
74
- # @return [True] 数値
75
- # @return [False] 非数値
76
- #
77
- def self.num?(str: '')
78
- return true if str == EMPTY_STRING
70
+ #
71
+ # 数値か
72
+ #
73
+ # @param [String] str 対象文字列
74
+ #
75
+ # @return [True] 数値
76
+ # @return [False] 非数値
77
+ #
78
+ def num?(str: '')
79
+ return true if str == EMPTY_STRING
79
80
 
80
- return false unless str
81
+ return false unless str
81
82
 
82
- /^[-0-9]+$/.match?(str)
83
- end
83
+ /^[-0-9]+$/.match?(str)
84
+ end
84
85
 
85
- #
86
- # booleanか
87
- #
88
- # @param [String] str 対象文字列
89
- #
90
- # @return [True] boolean
91
- # @return [False] 非boolean
92
- #
93
- def self.bool?(str: '')
94
- BOOLEANS.include?(str)
95
- end
86
+ #
87
+ # booleanか
88
+ #
89
+ # @param [String] str 対象文字列
90
+ #
91
+ # @return [True] boolean
92
+ # @return [False] 非boolean
93
+ #
94
+ def bool?(str: '')
95
+ BOOLEANS.include?(str)
96
+ end
96
97
 
97
- #
98
- # boolean(空許容)か
99
- #
100
- # @param [String] str 対象文字列
101
- #
102
- # @return [True] boolean
103
- # @return [False] 非boolean
104
- #
105
- def self.empiable_bool?(str: '')
106
- return true if str == EMPTY_STRING
98
+ #
99
+ # boolean(空許容)か
100
+ #
101
+ # @param [String] str 対象文字列
102
+ #
103
+ # @return [True] boolean
104
+ # @return [False] 非boolean
105
+ #
106
+ def empiable_bool?(str: '')
107
+ return true if str == EMPTY_STRING
107
108
 
108
- bool?(str: str)
109
- end
109
+ bool?(str: str)
110
+ end
110
111
 
111
- #
112
- # 月差分か
113
- #
114
- # @param [String] str 対象文字列
115
- #
116
- # @return [True] 有効
117
- # @return [False] 無効
118
- #
119
- def self.month_days?(str: '')
120
- return true if str == EMPTY_STRING
112
+ #
113
+ # 月差分か
114
+ #
115
+ # @param [String] str 対象文字列
116
+ #
117
+ # @return [True] 有効
118
+ # @return [False] 無効
119
+ #
120
+ def month_days?(str: '')
121
+ return true if str == EMPTY_STRING
121
122
 
122
- return false unless str
123
+ return false unless str
123
124
 
124
- /^[大小]$/.match?(str)
125
- end
125
+ /^[大小]$/.match?(str)
126
+ end
126
127
 
127
- #
128
- # 西暦日か
129
- #
130
- # @param [String] str 対象文字列
131
- #
132
- # @return [True] 有効
133
- # @return [False] 無効
134
- #
135
- def self.western_date?(str: '')
136
- return Western::Calendar.new if str == EMPTY_STRING
128
+ #
129
+ # 西暦日か
130
+ #
131
+ # @param [String] str 対象文字列
132
+ #
133
+ # @return [True] 有効
134
+ # @return [False] 無効
135
+ #
136
+ def western_date?(str: '')
137
+ return Western::Calendar.new if str == EMPTY_STRING
137
138
 
138
- Western::Calendar.valid_date_string(str: str)
139
+ Western::Calendar.valid_date_string(text: str)
140
+ end
139
141
  end
140
142
  end
141
143
 
@@ -381,9 +383,9 @@ module Zakuro
381
383
 
382
384
  prefix = "[#{@index}] invalid"
383
385
 
384
- failed += @month.validate
386
+ failed += month.validate
385
387
 
386
- failed += @solar_term.validate
388
+ failed += solar_term.validate
387
389
 
388
390
  failed.push("#{prefix} 'days'. #{@days}") unless days?
389
391
 
@@ -432,11 +434,11 @@ module Zakuro
432
434
  def validate
433
435
  failed = []
434
436
 
435
- failed += @number.validate
437
+ failed += number.validate
436
438
 
437
- failed += @leaped.validate
439
+ failed += leaped.validate
438
440
 
439
- failed += @days.validate
441
+ failed += days.validate
440
442
 
441
443
  failed
442
444
  end
@@ -461,19 +463,19 @@ module Zakuro
461
463
  #
462
464
  # @param [Integer] index 連番
463
465
  # @param [Hash<String, Object>] yaml_hash yaml
464
- # @option yaml_hash [Hash] :calc 移動元
465
- # @option yaml_hash [Hash] :actual 移動先
466
+ # @option yaml_hash [Hash] :src 移動元
467
+ # @option yaml_hash [Hash] :dest 移動先
466
468
  # @option yaml_hash [String] :days 中気差分
467
469
  #
468
470
  def initialize(index:, yaml_hash: {})
469
471
  @index = index
470
- @source = Source.new(diff_index: index, yaml_hash: yaml_hash['calc'])
471
- @destination = Destination.new(diff_index: index, yaml_hash: yaml_hash['actual'])
472
+ @source = Source.new(diff_index: index, yaml_hash: yaml_hash['src'])
473
+ @destination = Destination.new(diff_index: index, yaml_hash: yaml_hash['dest'])
472
474
  @days = yaml_hash['days']
473
475
  end
474
476
 
475
477
  def days?
476
- Types.positive?(str: @days)
478
+ Types.positive?(str: days)
477
479
  end
478
480
 
479
481
  # :reek:TooManyStatements { max_statements: 6 }
@@ -488,9 +490,9 @@ module Zakuro
488
490
 
489
491
  prefix = "[#{index}][solar_term] invalid"
490
492
 
491
- failed += @source.validate
493
+ failed += source.validate
492
494
 
493
- failed += @destination.validate
495
+ failed += destination.validate
494
496
 
495
497
  failed.push("#{prefix} 'days'. #{@days}") unless days?
496
498
 
@@ -537,27 +539,27 @@ module Zakuro
537
539
  def validate
538
540
  failed = []
539
541
 
540
- prefix = "[#{@diff_index}][solar_term.calc] invalid"
542
+ prefix = "[#{diff_index}][solar_term.src] invalid"
541
543
 
542
- failed.push("#{prefix} 'index'. #{@index}") unless index?
544
+ failed.push("#{prefix} 'index'. #{index}") unless index?
543
545
 
544
- failed.push("#{prefix} 'to'. #{@to}") unless to?
546
+ failed.push("#{prefix} 'to'. #{to}") unless to?
545
547
 
546
- failed.push("#{prefix} 'zodiac_name'. #{@zodiac_name}") unless zodiac_name?
548
+ failed.push("#{prefix} 'zodiac_name'. #{zodiac_name}") unless zodiac_name?
547
549
 
548
550
  failed
549
551
  end
550
552
 
551
553
  def index?
552
- Types.positive?(str: @index)
554
+ Types.positive?(str: index)
553
555
  end
554
556
 
555
557
  def to?
556
- Types.western_date?(str: @to)
558
+ Types.western_date?(str: to)
557
559
  end
558
560
 
559
561
  def zodiac_name?
560
- Types.string?(str: @zodiac_name)
562
+ Types.string?(str: zodiac_name)
561
563
  end
562
564
  end
563
565
 
@@ -600,27 +602,27 @@ module Zakuro
600
602
  def validate
601
603
  failed = []
602
604
 
603
- prefix = "[#{@diff_index}][solar_term.actual] invalid"
605
+ prefix = "[#{diff_index}][solar_term.dest] invalid"
604
606
 
605
- failed.push("#{prefix} 'index'. #{@index}") unless index?
607
+ failed.push("#{prefix} 'index'. #{index}") unless index?
606
608
 
607
- failed.push("#{prefix} 'from'. #{@from}") unless from?
609
+ failed.push("#{prefix} 'from'. #{from}") unless from?
608
610
 
609
- failed.push("#{prefix} 'zodiac_name'. #{@zodiac_name}") unless zodiac_name?
611
+ failed.push("#{prefix} 'zodiac_name'. #{zodiac_name}") unless zodiac_name?
610
612
 
611
613
  failed
612
614
  end
613
615
 
614
616
  def index?
615
- Types.positive?(str: @index)
617
+ Types.positive?(str: index)
616
618
  end
617
619
 
618
620
  def from?
619
- Types.western_date?(str: @from)
621
+ Types.western_date?(str: from)
620
622
  end
621
623
 
622
624
  def zodiac_name?
623
- Types.string?(str: @zodiac_name)
625
+ Types.string?(str: zodiac_name)
624
626
  end
625
627
  end
626
628
  end
@@ -633,23 +635,23 @@ module Zakuro
633
635
 
634
636
  # @return [Integer] 連番
635
637
  attr_reader :index
636
- # @return [String] 計算
637
- attr_reader :calc
638
- # @return [String] 運用
639
- attr_reader :actual
638
+ # @return [String] 移動元
639
+ attr_reader :src
640
+ # @return [String] 移動先
641
+ attr_reader :dest
640
642
 
641
643
  #
642
644
  # 初期化
643
645
  #
644
646
  # @param [Integer] index 連番
645
647
  # @param [Hash<String, String>] yaml_hash yaml
646
- # @option yaml_hash [String] :calc 計算
647
- # @option yaml_hash [String] :actual 運用
648
+ # @option yaml_hash [String] :src 移動元
649
+ # @option yaml_hash [String] :dest 移動先
648
650
  #
649
651
  def initialize(index:, yaml_hash: {})
650
652
  @index = index
651
- @calc = yaml_hash['calc']
652
- @actual = yaml_hash['actual']
653
+ @src = yaml_hash['src']
654
+ @dest = yaml_hash['dest']
653
655
  end
654
656
 
655
657
  #
@@ -660,21 +662,21 @@ module Zakuro
660
662
  def validate
661
663
  failed = []
662
664
 
663
- prefix = "[#{@index}][#{NAME}] invalid"
665
+ prefix = "[#{index}][#{NAME}] invalid"
664
666
 
665
- failed.push("#{prefix} 'calc'. #{@calc}") unless calc?
667
+ failed.push("#{prefix} 'src'. #{src}") unless src?
666
668
 
667
- failed.push("#{prefix} 'actual'. #{@actual}") unless actual?
669
+ failed.push("#{prefix} 'dest'. #{dest}") unless dest?
668
670
 
669
671
  failed
670
672
  end
671
673
 
672
- def calc?
673
- Types.positive?(str: @calc)
674
+ def src?
675
+ Types.positive?(str: src)
674
676
  end
675
677
 
676
- def actual?
677
- Types.positive?(str: @actual)
678
+ def dest?
679
+ Types.positive?(str: dest)
678
680
  end
679
681
  end
680
682
 
@@ -686,23 +688,23 @@ module Zakuro
686
688
 
687
689
  # @return [Integer] 連番
688
690
  attr_reader :index
689
- # @return [String] 計算
690
- attr_reader :calc
691
- # @return [String] 運用
692
- attr_reader :actual
691
+ # @return [String] 移動元
692
+ attr_reader :src
693
+ # @return [String] 移動先
694
+ attr_reader :dest
693
695
 
694
696
  #
695
697
  # 初期化
696
698
  #
697
699
  # @param [Integer] index 連番
698
700
  # @param [Hash<String, String>] yaml_hash yaml
699
- # @option yaml_hash [String] :calc 計算
700
- # @option yaml_hash [String] :actual 運用
701
+ # @option yaml_hash [String] :src 移動元
702
+ # @option yaml_hash [String] :dest 移動先
701
703
  #
702
704
  def initialize(index:, yaml_hash: {})
703
705
  @index = index
704
- @calc = yaml_hash['calc']
705
- @actual = yaml_hash['actual']
706
+ @src = yaml_hash['src']
707
+ @dest = yaml_hash['dest']
706
708
  end
707
709
 
708
710
  #
@@ -713,21 +715,21 @@ module Zakuro
713
715
  def validate
714
716
  failed = []
715
717
 
716
- prefix = "[#{@index}][#{NAME}] invalid"
718
+ prefix = "[#{index}][#{NAME}] invalid"
717
719
 
718
- failed.push("#{prefix} 'calc'. #{@calc}") unless calc?
720
+ failed.push("#{prefix} 'src'. #{src}") unless src?
719
721
 
720
- failed.push("#{prefix} 'actual'. #{@actual}") unless actual?
722
+ failed.push("#{prefix} 'dest'. #{dest}") unless dest?
721
723
 
722
724
  failed
723
725
  end
724
726
 
725
- def calc?
726
- Types.empiable_bool?(str: @calc)
727
+ def src?
728
+ Types.empiable_bool?(str: src)
727
729
  end
728
730
 
729
- def actual?
730
- Types.empiable_bool?(str: @actual)
731
+ def dest?
732
+ Types.empiable_bool?(str: dest)
731
733
  end
732
734
  end
733
735
 
@@ -739,23 +741,23 @@ module Zakuro
739
741
 
740
742
  # @return [Integer] 連番
741
743
  attr_reader :index
742
- # @return [String] 計算
743
- attr_reader :calc
744
- # @return [String] 運用
745
- attr_reader :actual
744
+ # @return [String] 移動元
745
+ attr_reader :src
746
+ # @return [String] 移動先
747
+ attr_reader :dest
746
748
 
747
749
  #
748
750
  # 初期化
749
751
  #
750
752
  # @param [Integer] index 連番
751
753
  # @param [Hash<String, String>] yaml_hash yaml
752
- # @option yaml_hash [String] :calc 計算
753
- # @option yaml_hash [String] :actual 運用
754
+ # @option yaml_hash [String] :src 移動元
755
+ # @option yaml_hash [String] :dest 移動先
754
756
  #
755
757
  def initialize(index:, yaml_hash: {})
756
758
  @index = index
757
- @calc = yaml_hash['calc']
758
- @actual = yaml_hash['actual']
759
+ @src = yaml_hash['src']
760
+ @dest = yaml_hash['dest']
759
761
  end
760
762
 
761
763
  #
@@ -766,36 +768,38 @@ module Zakuro
766
768
  def validate
767
769
  failed = []
768
770
 
769
- prefix = "[#{@index}][#{NAME}] invalid"
771
+ prefix = "[#{index}][#{NAME}] invalid"
770
772
 
771
- failed.push("#{prefix} 'calc'. #{@calc}") unless calc?
773
+ failed.push("#{prefix} 'src'. #{src}") unless src?
772
774
 
773
- failed.push("#{prefix} 'actual'. #{@actual}") unless actual?
775
+ failed.push("#{prefix} 'dest'. #{dest}") unless dest?
774
776
 
775
777
  failed
776
778
  end
777
779
 
778
- def calc?
779
- Types.month_days?(str: @calc)
780
+ def src?
781
+ Types.month_days?(str: src)
780
782
  end
781
783
 
782
- def actual?
783
- Types.month_days?(str: @actual)
784
+ def dest?
785
+ Types.month_days?(str: dest)
784
786
  end
785
787
  end
786
788
 
787
789
  # :reek:TooManyStatements { max_statements: 7 }
788
790
 
789
- def self.run(yaml_hash: {})
790
- failed = []
791
- yaml_hash.each_with_index do |history, index|
792
- failed += MonthHistory.new(index: index, yaml_hash: history).validate
793
- failed += Annotation.new(index: index, yaml_hash: history).validate
794
- failed += Reference.new(index: index, yaml_hash: history).validate
795
- failed += Diffs.new(index: index, yaml_hash: history['diffs']).validate
796
- end
791
+ class << self
792
+ def run(yaml_hash: {})
793
+ failed = []
794
+ yaml_hash.each_with_index do |history, index|
795
+ failed += MonthHistory.new(index: index, yaml_hash: history).validate
796
+ failed += Annotation.new(index: index, yaml_hash: history).validate
797
+ failed += Reference.new(index: index, yaml_hash: history).validate
798
+ failed += Diffs.new(index: index, yaml_hash: history['diffs']).validate
799
+ end
797
800
 
798
- failed
801
+ failed
802
+ end
799
803
  end
800
804
  end
801
805
  end
@@ -16,51 +16,53 @@ module Zakuro
16
16
  __dir__
17
17
  ))
18
18
 
19
- #
20
- # 変更履歴(月)を返す
21
- #
22
- # @return [Array<MonthHistory>] 変更履歴
23
- #
24
- def self.month_histories
25
- MONTH_HISTORIES
26
- end
19
+ class << self
20
+ #
21
+ # 変更履歴(月)を返す
22
+ #
23
+ # @return [Array<MonthHistory>] 変更履歴
24
+ #
25
+ def month_histories
26
+ MONTH_HISTORIES
27
+ end
27
28
 
28
- # :reek:ControlParameter
29
+ # :reek:ControlParameter
29
30
 
30
- #
31
- # 変更履歴を特定する
32
- #
33
- # @param [Western::Calendar] western_date 月初日の西暦日
34
- #
35
- # @return [Operation::MonthHistory] 変更履歴
36
- #
37
- def self.specify_history(western_date:)
38
- month_histroies = Operation.month_histories
31
+ #
32
+ # 変更履歴を特定する
33
+ #
34
+ # @param [Western::Calendar] western_date 月初日の西暦日
35
+ #
36
+ # @return [Operation::MonthHistory] 変更履歴
37
+ #
38
+ def specify_history(western_date:)
39
+ month_histroies = month_histories
40
+
41
+ month_histroies.each do |history|
42
+ return history if western_date == history.western_date
43
+ end
39
44
 
40
- month_histroies.each do |history|
41
- return history if western_date == history.western_date
45
+ Operation::MonthHistory.new
42
46
  end
43
47
 
44
- Operation::MonthHistory.new
45
- end
48
+ # :reek:ControlParameter
46
49
 
47
- # :reek:ControlParameter
50
+ #
51
+ # 変更履歴を特定する
52
+ #
53
+ # @param [Western::Calendar] id 変更履歴ID
54
+ #
55
+ # @return [Operation::MonthHistory] 変更履歴
56
+ #
57
+ def specify_history_by_id(id:)
58
+ month_histroies = month_histories
48
59
 
49
- #
50
- # 変更履歴を特定する
51
- #
52
- # @param [Western::Calendar] id 変更履歴ID
53
- #
54
- # @return [Operation::MonthHistory] 変更履歴
55
- #
56
- def self.specify_history_by_id(id:)
57
- month_histroies = Operation.month_histories
60
+ month_histroies.each do |history|
61
+ return history if id == history.id
62
+ end
58
63
 
59
- month_histroies.each do |history|
60
- return history if id == history.id
64
+ Operation::MonthHistory.new
61
65
  end
62
-
63
- Operation::MonthHistory.new
64
66
  end
65
67
  end
66
68
  end