zakuro 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +33 -20
  3. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +9 -7
  4. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +19 -0
  5. data/lib/zakuro/era/japan/reki.rb +1 -1
  6. data/lib/zakuro/version.rb +1 -1
  7. data/lib/zakuro/version/context.rb +1 -1
  8. data/lib/zakuro/version/daien/const/number.rb +55 -0
  9. data/lib/zakuro/version/daien/const/remainder.rb +53 -0
  10. data/lib/zakuro/version/daien/cycle/remainder.rb +59 -0
  11. data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
  12. data/lib/zakuro/version/daien/daien.rb +36 -0
  13. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
  14. data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
  15. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
  16. data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
  17. data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
  18. data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
  19. data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
  20. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
  21. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
  22. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
  23. data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
  24. data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
  25. data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
  26. data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
  27. data/lib/zakuro/version/gihou/const/remainder.rb +0 -2
  28. data/lib/zakuro/version/gihou/cycle/remainder.rb +1 -6
  29. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +1 -1
  30. data/lib/zakuro/version/gihou/stella/lunar/location.rb +2 -8
  31. data/lib/zakuro/version/gihou/stella/lunar/value.rb +3 -2
  32. data/lib/zakuro/version/gihou/stella/solar/average.rb +1 -1
  33. data/lib/zakuro/version/senmyou/const/remainder.rb +0 -2
  34. data/lib/zakuro/version/senmyou/cycle/remainder.rb +1 -6
  35. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +1 -1
  36. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +2 -8
  37. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +3 -2
  38. data/lib/zakuro/version/senmyou/stella/solar/average.rb +1 -1
  39. data/lib/zakuro/version/version_class_resolver.rb +4 -0
  40. data/lib/zakuro/version_factory.rb +1 -1
  41. metadata +25 -7
  42. data/lib/zakuro/version/taien/taien.rb +0 -19
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../calculation/stella/solar/abstract_location'
4
+
5
+ require_relative '../../const/remainder'
6
+
7
+ require_relative './interval'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Daien
13
+ # :nodoc:
14
+ module Solar
15
+ #
16
+ # Location 入定気
17
+ #
18
+ class Location < Calculation::Solar::AbstractLocation
19
+ # @return [Cycle::Remainder] 弦
20
+ QUARTER = Const::Remainder::Solar::QUARTER
21
+
22
+ #
23
+ # 初期化
24
+ #
25
+ # @param [Cycle::Remainder] lunar_age 天正閏余(大余小余)
26
+ #
27
+ def initialize(lunar_age:)
28
+ super(lunar_age: lunar_age, quarter: QUARTER)
29
+ end
30
+
31
+ # :reek:UtilityFunction
32
+
33
+ #
34
+ # 二十四節気番号に対応する入気定日加減数を返す
35
+ #
36
+ # @note 継承のためクラスメソッドにしない
37
+ #
38
+ # @param [Integer] index 二十四節気番号
39
+ #
40
+ # @return [Cycle::Remainder] 入気定日加減数
41
+ #
42
+ def interval(index:)
43
+ Interval.index_of(index)
44
+ end
45
+
46
+ # :reek:UtilityFunction
47
+
48
+ #
49
+ # 入気定日加減数の要素数を返す
50
+ #
51
+ # @note 継承のためクラスメソッドにしない
52
+ #
53
+ # @return [Integer] 入気定日加減数の要素数
54
+ #
55
+ def interval_size
56
+ Interval.size
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../calculation/stella/solar/choukei_value'
4
+
5
+ require_relative '../../const/number'
6
+
7
+ require_relative './adjustment'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Daien
13
+ # :nodoc:
14
+ module Solar
15
+ #
16
+ # Value 太陽補正値
17
+ #
18
+ module Value
19
+ #
20
+ # 太陽の運行による補正値を算出する
21
+ #
22
+ # @param [SolarTerm] solar_location 入定気
23
+ #
24
+ # @return [Integer] 補正値
25
+ #
26
+ def self.get(solar_location:)
27
+ remainder = solar_location.remainder
28
+
29
+ row = Adjustment.specify(index: solar_location.index)
30
+
31
+ Calculation::Solar::ChoukeiValue.get(remainder: remainder, row: row)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -36,8 +36,6 @@ module Zakuro
36
36
  # @return [Cycle::LunarRemainder] 変日(1近点月)
37
37
  ANOMALISTIC_MONTH = \
38
38
  Cycle::LunarRemainder.new(day: 27, minute: 743, second: 1)
39
- # @return [Cycle::LunarRemainder] 入暦上限
40
- LIMIT = Cycle::LunarRemainder.new(day: 28, minute: 743, second: 0)
41
39
  #
42
40
  # @note 常朔実 39571 = 29-711
43
41
  # * 39571 / 4 = 9892.75 / 1340 = 7 余り 512.75
@@ -11,12 +11,7 @@ module Zakuro
11
11
  # :nodoc:
12
12
  module Cycle
13
13
  #
14
- # Remainder 宣明暦の時刻情報(大余小余)
15
- #
16
- # * 「15日1012分5秒」のような形式で表される
17
- # * 分は1340で一日に繰り上げる
18
- # * 秒は基本的に1/6分で、6秒で1分に繰り上げる。ただし、月補正値は1分に100秒とするなど基数の変更がありえる
19
- # * 十干十二支(60日)を上限とした「日時分秒」の情報で、日付(date)/時刻(time)と部分的に重なる概念
14
+ # Remainder 時刻情報(大余小余)
20
15
  #
21
16
  class Remainder < Calculation::Cycle::AbstractRemainder
22
17
  # @return [Integer] 分(1分=6秒)
@@ -92,7 +92,7 @@ module Zakuro
92
92
  def correction_moon_value
93
93
  @lunar_location.run
94
94
 
95
- remainder = @lunar_location.remainder
95
+ remainder = @lunar_location.adjusted_remainder
96
96
 
97
97
  # debug("[lunar]remainder.format: #{remainder.format(form: '%d-%d-%.5f')}")
98
98
  # debug("[lunar]remainder.day: #{remainder.day}")
@@ -18,8 +18,6 @@ module Zakuro
18
18
  class Location < Calculation::Lunar::AbstractLocation
19
19
  # @return [Cycle::LunarRemainder] 1近点月
20
20
  ANOMALISTIC_MONTH = Const::Remainder::Lunar::ANOMALISTIC_MONTH
21
- # @return [Cycle::LunarRemainder] 入暦上限
22
- LIMIT = Const::Remainder::Lunar::LIMIT
23
21
  # @return [Cycle::LunarRemainder] 弦
24
22
  QUARTER = Const::Remainder::Lunar::QUARTER
25
23
 
@@ -38,8 +36,7 @@ module Zakuro
38
36
  #
39
37
  def run
40
38
  if calculated
41
- # 1始まりで計算しているので、入暦上限を用いる
42
- decrease(limit: LIMIT)
39
+ decrease(limit: ANOMALISTIC_MONTH)
43
40
  return
44
41
  end
45
42
 
@@ -62,10 +59,7 @@ module Zakuro
62
59
  @remainder = Localization.first_remainder(
63
60
  lunar_age: remainder, western_year: western_year
64
61
  )
65
- # 初回は0始まりで計算しているので、入暦上限ではなく1近点月を用いる
66
62
  decrease(limit: ANOMALISTIC_MONTH)
67
- # 1始まりに改める
68
- one_based
69
63
 
70
64
  @calculated = true
71
65
  end
@@ -78,7 +72,7 @@ module Zakuro
78
72
  def decrease(limit:)
79
73
  return if remainder < limit
80
74
 
81
- remainder.sub!(ANOMALISTIC_MONTH)
75
+ remainder.sub!(limit)
82
76
  end
83
77
  end
84
78
  end
@@ -31,8 +31,9 @@ module Zakuro
31
31
  def self.get(remainder:)
32
32
  valid?(remainder: remainder)
33
33
 
34
- day = remainder.day
35
- minute = remainder.floor_minute
34
+ day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
35
+ remainder: remainder
36
+ )
36
37
 
37
38
  # 引き当て
38
39
  row = Adjustment.specify(day: day, minute: minute)
@@ -87,7 +87,7 @@ module Zakuro
87
87
  solar_term_index = solar_location.index
88
88
 
89
89
  # 入定気の一つ後の二十四節気まで戻す(ただし11月経朔が二十四節気上にある場合は戻さない)
90
- solar_term_index += 1 unless solar_location.remainder == Cycle::Remainder.new(total: 0)
90
+ solar_term_index += 1 unless solar_location.remainder.day.zero?
91
91
 
92
92
  solar_term_index
93
93
  end
@@ -35,8 +35,6 @@ module Zakuro
35
35
  # @note ANOMALISTIC_MONTH (1近点月)の半分に相当する
36
36
  HALF_ANOMALISTIC_MONTH = \
37
37
  Cycle::LunarRemainder.new(day: 13, minute: 6529, second: 9.5)
38
- # @return [Cycle::LunarRemainder] 入暦上限
39
- LIMIT = Cycle::LunarRemainder.new(day: 14, minute: 6529, second: 0)
40
38
  #
41
39
  # @note 章月 248057 = 29-4457
42
40
  #
@@ -11,12 +11,7 @@ module Zakuro
11
11
  # :nodoc:
12
12
  module Cycle
13
13
  #
14
- # Remainder 宣明暦の時刻情報(大余小余)
15
- #
16
- # * 「15日1835分5秒」のような形式で表される
17
- # * 分は8400で一日に繰り上げる
18
- # * 秒は基本的に1/8分で、8秒で1分に繰り上げる。ただし、月補正値は1分に100秒とするなど基数の変更がありえる
19
- # * 十干十二支(60日)を上限とした「日時分秒」の情報で、日付(date)/時刻(time)と部分的に重なる概念
14
+ # Remainder 時刻情報(大余小余)
20
15
  #
21
16
  class Remainder < Calculation::Cycle::AbstractRemainder
22
17
  # @return [Integer] 分(1分=8秒)
@@ -91,7 +91,7 @@ module Zakuro
91
91
  def correction_moon_value
92
92
  @lunar_location.run
93
93
 
94
- remainder = @lunar_location.remainder
94
+ remainder = @lunar_location.adjusted_remainder
95
95
  forward = @lunar_location.forward
96
96
 
97
97
  debug("[lunar]remainder.format: #{remainder.format}")
@@ -18,8 +18,6 @@ module Zakuro
18
18
  class Location < Calculation::Lunar::AbstractLocation
19
19
  # @return [Cycle::LunarRemainder] 暦中日(1近点月の半分)
20
20
  HALF_ANOMALISTIC_MONTH = Const::Remainder::Lunar::HALF_ANOMALISTIC_MONTH
21
- # @return [Cycle::LunarRemainder] 入暦上限
22
- LIMIT = Const::Remainder::Lunar::LIMIT
23
21
  # @return [Cycle::LunarRemainder] 弦
24
22
  QUARTER = Const::Remainder::Lunar::QUARTER
25
23
 
@@ -44,8 +42,7 @@ module Zakuro
44
42
  #
45
43
  def run
46
44
  if calculated
47
- # 1始まりで計算しているので、入暦上限を用いる
48
- decrease(limit: LIMIT)
45
+ decrease(limit: HALF_ANOMALISTIC_MONTH)
49
46
  return
50
47
  end
51
48
 
@@ -68,10 +65,7 @@ module Zakuro
68
65
  @remainder = Localization.first_remainder(
69
66
  lunar_age: remainder, western_year: western_year
70
67
  )
71
- # 初回は0始まりで計算しているので、入暦上限ではなく暦中日を用いる
72
68
  decrease(limit: HALF_ANOMALISTIC_MONTH)
73
- # 1始まりに改める
74
- one_based
75
69
 
76
70
  @calculated = true
77
71
  end
@@ -84,7 +78,7 @@ module Zakuro
84
78
  def decrease(limit:)
85
79
  return if remainder < limit
86
80
 
87
- remainder.sub!(HALF_ANOMALISTIC_MONTH)
81
+ remainder.sub!(limit)
88
82
  @forward = !forward
89
83
  end
90
84
  end
@@ -29,8 +29,9 @@ module Zakuro
29
29
  def self.get(remainder:, forward:)
30
30
  valid?(remainder: remainder)
31
31
 
32
- day = remainder.day
33
- minute = remainder.floor_minute
32
+ day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
33
+ remainder: remainder
34
+ )
34
35
 
35
36
  # 引き当て
36
37
  row = Adjustment.specify(forward: forward, day: day, minute: minute)
@@ -87,7 +87,7 @@ module Zakuro
87
87
  solar_term_index = solar_location.index
88
88
 
89
89
  # 入定気の一つ後の二十四節気まで戻す(ただし11月経朔が二十四節気上にある場合は戻さない)
90
- solar_term_index += 1 unless solar_location.remainder == Cycle::Remainder.new(total: 0)
90
+ solar_term_index += 1 unless solar_location.remainder.day.zero?
91
91
 
92
92
  solar_term_index
93
93
  end
@@ -4,6 +4,10 @@ require_relative './gihou/cycle/remainder'
4
4
  require_relative './gihou/cycle/solar_term'
5
5
  require_relative './gihou/range/annual_range'
6
6
 
7
+ require_relative './daien/cycle/remainder'
8
+ require_relative './daien/cycle/solar_term'
9
+ require_relative './daien/range/annual_range'
10
+
7
11
  require_relative './senmyou/cycle/remainder'
8
12
  require_relative './senmyou/cycle/solar_term'
9
13
  require_relative './senmyou/range/annual_range'
@@ -4,7 +4,7 @@ require_relative './era/japan/reki'
4
4
  require_relative './era/western'
5
5
  require_relative './version/genka/genka'
6
6
  require_relative './version/gihou/gihou'
7
- require_relative './version/taien/taien'
7
+ require_relative './version/daien/daien'
8
8
  require_relative './version/senmyou/senmyou'
9
9
  require_relative './version/joukyou/joukyou'
10
10
  require_relative './version/houryaku/houryaku'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zakuro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pldb
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-06 00:00:00.000000000 Z
11
+ date: 2021-07-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: mainly lunar solar calendar
14
14
  email:
@@ -94,6 +94,25 @@ files:
94
94
  - lib/zakuro/version.rb
95
95
  - lib/zakuro/version/abstract_version.rb
96
96
  - lib/zakuro/version/context.rb
97
+ - lib/zakuro/version/daien/const/number.rb
98
+ - lib/zakuro/version/daien/const/remainder.rb
99
+ - lib/zakuro/version/daien/cycle/remainder.rb
100
+ - lib/zakuro/version/daien/cycle/solar_term.rb
101
+ - lib/zakuro/version/daien/daien.rb
102
+ - lib/zakuro/version/daien/monthly/lunar_phase.rb
103
+ - lib/zakuro/version/daien/range/annual_range.rb
104
+ - lib/zakuro/version/daien/stella/lunar/adjustment.rb
105
+ - lib/zakuro/version/daien/stella/lunar/localization.rb
106
+ - lib/zakuro/version/daien/stella/lunar/location.rb
107
+ - lib/zakuro/version/daien/stella/lunar/value.rb
108
+ - lib/zakuro/version/daien/stella/origin/average_november.rb
109
+ - lib/zakuro/version/daien/stella/origin/lunar_age.rb
110
+ - lib/zakuro/version/daien/stella/origin/winter_solstice.rb
111
+ - lib/zakuro/version/daien/stella/solar/adjustment.rb
112
+ - lib/zakuro/version/daien/stella/solar/average.rb
113
+ - lib/zakuro/version/daien/stella/solar/interval.rb
114
+ - lib/zakuro/version/daien/stella/solar/location.rb
115
+ - lib/zakuro/version/daien/stella/solar/value.rb
97
116
  - lib/zakuro/version/genka/genka.rb
98
117
  - lib/zakuro/version/gihou/const/number.rb
99
118
  - lib/zakuro/version/gihou/const/remainder.rb
@@ -138,7 +157,6 @@ files:
138
157
  - lib/zakuro/version/senmyou/stella/solar/interval.rb
139
158
  - lib/zakuro/version/senmyou/stella/solar/location.rb
140
159
  - lib/zakuro/version/senmyou/stella/solar/value.rb
141
- - lib/zakuro/version/taien/taien.rb
142
160
  - lib/zakuro/version/tenpou/tenpou.rb
143
161
  - lib/zakuro/version/version_class_resolver.rb
144
162
  - lib/zakuro/version_factory.rb
@@ -151,7 +169,7 @@ metadata:
151
169
  homepage_uri: https://github.com/pldb/zakuro
152
170
  source_code_uri: https://github.com/pldb/zakuro
153
171
  changelog_uri: https://github.com/pldb/zakuro
154
- post_install_message:
172
+ post_install_message:
155
173
  rdoc_options: []
156
174
  require_paths:
157
175
  - lib
@@ -166,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
184
  - !ruby/object:Gem::Version
167
185
  version: '0'
168
186
  requirements: []
169
- rubygems_version: 3.1.4
170
- signing_key:
187
+ rubygems_version: 3.1.2
188
+ signing_key:
171
189
  specification_version: 4
172
190
  summary: japanese calendar library.
173
191
  test_files: []
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../abstract_version'
4
-
5
- # :nodoc:
6
- module Zakuro
7
- #
8
- # Taien 大衍暦
9
- #
10
- module Taien
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [False] リリースなし
16
- RELEASE = false
17
- end
18
- end
19
- end