four-pillars 0.1.16 → 0.1.18
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.
- checksums.yaml +4 -4
- data/lib/four-pillars.rb +40 -21
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4382511acd1f1368f0521311c524b106d043283e3c49b1493d8bb5dbd0035758
|
|
4
|
+
data.tar.gz: 66fa7174de02c05426e23bfd676deacec29a2fbea287da325e479a0737e608cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa40e2bdbf9e4ddf6b388fa501adc65e5fb60a2e0a31f9049501a4281d740d044af79a7daae2a72e7b5d20273247fa4e65ea4818b136167d895ff5a9c3de7884
|
|
7
|
+
data.tar.gz: f722c235c243890f782ad347310b790d3a7ed1dc80611516c901753fa7c766e7c49955804a715a261f8390bc3f6d95c11b2b83d4b93d9c6f4215e1d368d9f2a0
|
data/lib/four-pillars.rb
CHANGED
|
@@ -42,6 +42,16 @@ class FourPillarsLogic
|
|
|
42
42
|
end
|
|
43
43
|
KANSHI_HASH = kanshi_hash
|
|
44
44
|
|
|
45
|
+
# 日柱の基準日 (この日が甲子)
|
|
46
|
+
KANSHI_BASE_DATE = Date.new(1863,12,31)
|
|
47
|
+
|
|
48
|
+
# 日付に対応する日柱(その日の干支)
|
|
49
|
+
# FourPillarsLogic.day_pillar_of(Date.new(2026,9,7)) #=> "甲申"
|
|
50
|
+
def self.day_pillar_of(date)
|
|
51
|
+
d = date.respond_to?(:to_date) ? date.to_date : date
|
|
52
|
+
KANSHI_ARRAY[(d - KANSHI_BASE_DATE).to_i % 60]
|
|
53
|
+
end
|
|
54
|
+
|
|
45
55
|
# 陰干通表
|
|
46
56
|
def self.jikkan_in
|
|
47
57
|
j = [nil] * 10
|
|
@@ -96,6 +106,12 @@ class FourPillarsLogic
|
|
|
96
106
|
end
|
|
97
107
|
SETSUIRI_HASH, SETSUIRI_LIST = load_setsuiri
|
|
98
108
|
|
|
109
|
+
# 年月に対応する節入り日時 (注:時 = 時間 x 60 + 分) 登録がない場合は nil
|
|
110
|
+
# FourPillarsLogic.setsuiri_of(2026,9) #=> [7, 1421] (7日 23時41分)
|
|
111
|
+
def self.setsuiri_of(year,month)
|
|
112
|
+
SETSUIRI_HASH[year*100+month]
|
|
113
|
+
end
|
|
114
|
+
|
|
99
115
|
# 通変星
|
|
100
116
|
def self.tsuhensei(j_day,j_src) # 日柱の十干、月柱または年柱の十干
|
|
101
117
|
if plus_jikkan?(j_day) # 陽
|
|
@@ -130,15 +146,16 @@ class FourPillarsLogic
|
|
|
130
146
|
# 生年月日時間, 性別(大運の向きに使用)
|
|
131
147
|
attr_reader :birth_dt, :gender
|
|
132
148
|
|
|
133
|
-
def initialize(birth_dt,gender,with_time:false)
|
|
134
|
-
@birth_dt = birth_dt.map {|v| v.
|
|
149
|
+
def initialize(birth_dt,gender,with_time:false,know_time:true)
|
|
150
|
+
@birth_dt = birth_dt.map {|v| v.to_i } # 時分がnilの場合、0になる
|
|
135
151
|
@gender = gender
|
|
136
152
|
@with_time = with_time
|
|
153
|
+
@know_time = know_time && birth_dt[3] != nil
|
|
137
154
|
raise "Incorrect birth date: #{birth_dt}" if @birth_dt.count != 5
|
|
138
155
|
raise "Gender must be m,f or o(other): #{gender}" unless ['o','m','f'].include? @gender
|
|
139
156
|
raise "Year must be larger than 1863" if @birth_dt[0] < 1864
|
|
140
157
|
h = @birth_dt[3]
|
|
141
|
-
if
|
|
158
|
+
if h < 0 || h > 23
|
|
142
159
|
raise "Invalid hour: #{birth_dt}"
|
|
143
160
|
end
|
|
144
161
|
end
|
|
@@ -154,10 +171,10 @@ class FourPillarsLogic
|
|
|
154
171
|
else
|
|
155
172
|
g = ""
|
|
156
173
|
end
|
|
157
|
-
if
|
|
158
|
-
t = ""
|
|
159
|
-
else
|
|
174
|
+
if @know_time
|
|
160
175
|
t = "#{h}時#{i}分"
|
|
176
|
+
else
|
|
177
|
+
t = ""
|
|
161
178
|
end
|
|
162
179
|
"#{y}年#{m}月#{d}日#{t}生 #{g}"
|
|
163
180
|
end
|
|
@@ -183,7 +200,7 @@ class FourPillarsLogic
|
|
|
183
200
|
else
|
|
184
201
|
m -= 1
|
|
185
202
|
end
|
|
186
|
-
|
|
203
|
+
self.class.setsuiri_of(y,m) || [0,0]
|
|
187
204
|
end
|
|
188
205
|
|
|
189
206
|
# 翌月の節入日
|
|
@@ -202,13 +219,13 @@ class FourPillarsLogic
|
|
|
202
219
|
# このメソッドがfalseを返す場合、干支、蔵干が仮の節入日で計算されています。
|
|
203
220
|
def know_setsuiri?
|
|
204
221
|
y,m,d,h,i = @birth_dt
|
|
205
|
-
|
|
222
|
+
!self.class.setsuiri_of(y,m).nil?
|
|
206
223
|
end
|
|
207
224
|
|
|
208
225
|
# 生年月に対応する節入り日時 ファイルに登録がない場合は、4日12時を返す
|
|
209
226
|
def setsuiri
|
|
210
227
|
y,m,d,h,i = @birth_dt
|
|
211
|
-
|
|
228
|
+
self.class.setsuiri_of(y,m) || [4,12*60]
|
|
212
229
|
end
|
|
213
230
|
|
|
214
231
|
# 生まれた日が節入日にあたる場合、true
|
|
@@ -223,21 +240,24 @@ class FourPillarsLogic
|
|
|
223
240
|
def kanshi
|
|
224
241
|
y,m,d,h,i = @birth_dt
|
|
225
242
|
sd, st = setsuiri
|
|
243
|
+
if d == sd
|
|
244
|
+
# puts "d=#{d}, h=#{h}, i=#{i}"
|
|
245
|
+
end
|
|
246
|
+
|
|
226
247
|
yd = y - 1864 # (till 1865.02.0?) = 甲子
|
|
227
248
|
yd -= 1 if m < 2 || (m == 2 && d < sd) || (m == 2 && d == sd && h*60+i < st)
|
|
228
249
|
md = (y - 1863) * 12 + (m - 12) # (till 1864.01.05) = 甲子
|
|
229
250
|
md -= 1 if d < sd || (d == sd && h*60+i < st)
|
|
230
|
-
|
|
251
|
+
dp = self.class.day_pillar_of(Date.new(y,m,d)) # 日柱
|
|
231
252
|
|
|
232
|
-
return [
|
|
253
|
+
return [dp,KANSHI_ARRAY[md % 60],KANSHI_ARRAY[yd % 60]] unless @with_time
|
|
233
254
|
|
|
234
|
-
|
|
235
|
-
if h.nil?
|
|
236
|
-
tp = nil
|
|
237
|
-
else
|
|
255
|
+
if @know_time
|
|
238
256
|
jyunishi_idx = h == 23 ? 0 : ((h + 1) / 2)
|
|
239
257
|
jikkan_idx = ((JIKKAN.index(dp[0]) % 5) * 2 + jyunishi_idx) % 10
|
|
240
258
|
tp = JIKKAN[jikkan_idx] + JYUNISHI[jyunishi_idx]
|
|
259
|
+
else
|
|
260
|
+
tp = nil
|
|
241
261
|
end
|
|
242
262
|
return [tp,dp,KANSHI_ARRAY[md % 60],KANSHI_ARRAY[yd % 60]]
|
|
243
263
|
end
|
|
@@ -368,10 +388,10 @@ class FourPillarsLogic
|
|
|
368
388
|
m = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[1 + o][1])
|
|
369
389
|
y = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[2 + o][1])
|
|
370
390
|
return [d,m,y] unless @with_time
|
|
371
|
-
if @
|
|
372
|
-
t = nil
|
|
373
|
-
else
|
|
391
|
+
if @know_time
|
|
374
392
|
t = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[0][1])
|
|
393
|
+
else
|
|
394
|
+
t = nil
|
|
375
395
|
end
|
|
376
396
|
[t,d,m,y]
|
|
377
397
|
end
|
|
@@ -533,9 +553,8 @@ class FourPillarsLogic
|
|
|
533
553
|
# 大運 [順行 or 逆行, year] or [nil,nil](if gender is not male nor female)
|
|
534
554
|
def taiun
|
|
535
555
|
return [nil,nil] unless ['m','f'].include? @gender
|
|
536
|
-
k = gogyo_jikkan[2][0]
|
|
537
|
-
#
|
|
538
|
-
t = @birth_dt[3] * 60 + @birth_dt[4] # 生まれた時間
|
|
556
|
+
k = gogyo_jikkan[2 + offset_for_day][0]
|
|
557
|
+
t = @birth_dt[3] * 60 + @birth_dt[4].to_i # 生まれた時間
|
|
539
558
|
if (@gender == 'm' && k == "+") || (@gender == 'f' && k == '-')
|
|
540
559
|
order = "順行"
|
|
541
560
|
d = setsuiri[0] - birth_dt[2]
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: four-pillars
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yosei Ito
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-09-20 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: A class which tells fortune by Four Pillar astrology(四柱推命).
|
|
14
13
|
email: y-itou@lumber-mill.co.jp
|
|
@@ -22,7 +21,6 @@ homepage: https://github.com/lumbermill/four-pillars
|
|
|
22
21
|
licenses:
|
|
23
22
|
- MIT
|
|
24
23
|
metadata: {}
|
|
25
|
-
post_install_message:
|
|
26
24
|
rdoc_options: []
|
|
27
25
|
require_paths:
|
|
28
26
|
- lib
|
|
@@ -37,8 +35,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
37
35
|
- !ruby/object:Gem::Version
|
|
38
36
|
version: '0'
|
|
39
37
|
requirements: []
|
|
40
|
-
rubygems_version:
|
|
41
|
-
signing_key:
|
|
38
|
+
rubygems_version: 4.0.19
|
|
42
39
|
specification_version: 4
|
|
43
40
|
summary: Four Pillar astrology
|
|
44
41
|
test_files: []
|