four-pillars 0.1.2 → 0.1.7
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 +202 -30
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b752a4fd5772f51f9e52f6ab16e73ad42f44b62fe4f2f054e92f970149198eb
|
4
|
+
data.tar.gz: e0c672183c4899d6081151d5c454a51b0ada0e4896280f954e8b3a30560f6387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53e3160379f66a383cdb6d9ac16b5dd360c56341e8cd5a860906bd4149ee2ff6f36bc57a82a76c8f89c1f2f7fc9ba0623142cd04fb84d920557a1ce346c35a0d
|
7
|
+
data.tar.gz: e6f4931e6fa5ebee31103d2961436394ebafa393b2a0f97d35acdcebfd48873189836cd9e6cc3d1986ec2a585db46129a0dcc81c4a772367a5fe2c4aad76ba7f
|
data/lib/four-pillars.rb
CHANGED
@@ -84,7 +84,34 @@ class FourPillarsLogic
|
|
84
84
|
end
|
85
85
|
SETSUIRI_HASH, SETSUIRI_LIST = load_setsuiri
|
86
86
|
|
87
|
-
#
|
87
|
+
# 通変星
|
88
|
+
def self.tsuhensei(j_day,j_src) # 日柱の十干、月柱または年柱の十干
|
89
|
+
j = JIKKAN.index(j_day)
|
90
|
+
if j % 2 == 0 # 陽
|
91
|
+
jikkan = JIKKAN
|
92
|
+
else # 陰
|
93
|
+
jikkan = JIKKAN_IN
|
94
|
+
end
|
95
|
+
t = jikkan.index(j_src) - jikkan.index(j_day)
|
96
|
+
t += 10 if t < 0
|
97
|
+
TSUHENSEI[t]
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.jyuniunsei(j_day,j_src) # 日柱の十干, 十二支
|
101
|
+
j = JIKKAN.index(j_day)
|
102
|
+
if j % 2 == 0 # 陽
|
103
|
+
jyunishi = JYUNISHI
|
104
|
+
else # 陰
|
105
|
+
jyunishi = JYUNISHI_IN
|
106
|
+
end
|
107
|
+
offset = [1,7,10,10,10,10,7,1,4,4][j] # 十二運表より求めたオフセット
|
108
|
+
ji = jyunishi.index(j_src)
|
109
|
+
JYUNIUNSEI[(ji + offset) % 12]
|
110
|
+
end
|
111
|
+
|
112
|
+
# TODO エネルギー
|
113
|
+
|
114
|
+
# 生年月日時間, 性別(大運の向きに使用)
|
88
115
|
attr_reader :birth_dt,:gender
|
89
116
|
|
90
117
|
def initialize(birth_dt,gender)
|
@@ -115,6 +142,12 @@ class FourPillarsLogic
|
|
115
142
|
(Date.new(y,m,1) - 1).day
|
116
143
|
end
|
117
144
|
|
145
|
+
# 今月の日数
|
146
|
+
def days_of_current_month
|
147
|
+
y,m,d,h,i = @birth_dt
|
148
|
+
Date.new(y,m,1).next_month.prev_day.day
|
149
|
+
end
|
150
|
+
|
118
151
|
# 前月の節入日
|
119
152
|
def setsuiri_of_previous_month
|
120
153
|
y,m,d,h,i = @birth_dt
|
@@ -127,6 +160,18 @@ class FourPillarsLogic
|
|
127
160
|
SETSUIRI_HASH[y*100+m] || [0,0]
|
128
161
|
end
|
129
162
|
|
163
|
+
# 翌月の節入日
|
164
|
+
def setsuiri_of_next_month
|
165
|
+
y,m,d,h,i = @birth_dt
|
166
|
+
if m == 12
|
167
|
+
y += 1
|
168
|
+
m = 1
|
169
|
+
else
|
170
|
+
m += 1
|
171
|
+
end
|
172
|
+
SETSUIRI_HASH[y*100+m] || [0,0]
|
173
|
+
end
|
174
|
+
|
130
175
|
# 生年月に対する節入日時を知っているか?
|
131
176
|
# このメソッドがfalseを返す場合、干支、蔵干が仮の節入日で計算されています。
|
132
177
|
def know_setsuiri?
|
@@ -213,20 +258,9 @@ class FourPillarsLogic
|
|
213
258
|
|
214
259
|
# 通変星(nil,月,年)
|
215
260
|
def tsuhensei
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
else # 陰
|
220
|
-
jikkan = JIKKAN_IN
|
221
|
-
end
|
222
|
-
j = jikkan.index(kanshi[0][0])
|
223
|
-
j_month = jikkan.index(kanshi[1][0])
|
224
|
-
j_year = jikkan.index(kanshi[2][0])
|
225
|
-
t_month = j_month - j
|
226
|
-
t_month += 10 if t_month < 0
|
227
|
-
t_year = j_year - j
|
228
|
-
t_year += 10 if t_year < 0
|
229
|
-
[nil,TSUHENSEI[t_month],TSUHENSEI[t_year]]
|
261
|
+
m = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[1][0])
|
262
|
+
y = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[2][0])
|
263
|
+
[nil,m,y]
|
230
264
|
end
|
231
265
|
|
232
266
|
# 蔵干通変星
|
@@ -252,20 +286,10 @@ class FourPillarsLogic
|
|
252
286
|
|
253
287
|
# 十二運星
|
254
288
|
def jyuniunsei
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
jyunishi = JYUNISHI_IN
|
260
|
-
end
|
261
|
-
offset = [1,7,10,10,10,10,7,1,4,4][j] # 十二運表より求めたオフセット
|
262
|
-
j_day = jyunishi.index(kanshi[0][1])
|
263
|
-
j_month = jyunishi.index(kanshi[1][1])
|
264
|
-
j_year = jyunishi.index(kanshi[2][1])
|
265
|
-
u_day = (j_day + offset) % 12
|
266
|
-
u_month = (j_month + offset) % 12
|
267
|
-
u_year = (j_year + offset) % 12
|
268
|
-
[JYUNIUNSEI[u_day],JYUNIUNSEI[u_month],JYUNIUNSEI[u_year]]
|
289
|
+
d = FourPillarsLogic::jyuniunsei(kanshi[0][0],kanshi[0][1])
|
290
|
+
m = FourPillarsLogic::jyuniunsei(kanshi[0][0],kanshi[1][1])
|
291
|
+
y = FourPillarsLogic::jyuniunsei(kanshi[0][0],kanshi[2][1])
|
292
|
+
[d,m,y]
|
269
293
|
end
|
270
294
|
|
271
295
|
def jyuniunsei_energy
|
@@ -313,11 +337,159 @@ class FourPillarsLogic
|
|
313
337
|
return arr
|
314
338
|
end
|
315
339
|
|
340
|
+
# 守護神
|
316
341
|
def shugoshin
|
317
342
|
# 日柱の十干と月柱の十二支
|
318
343
|
x = JIKKAN.index(kanshi[0][0])
|
319
344
|
y = JYUNISHI.index(kanshi[1][1])
|
320
|
-
SHUGOSHIN[y][x]
|
345
|
+
SHUGOSHIN[y][x].split("")
|
346
|
+
end
|
347
|
+
|
348
|
+
# 宿命中殺
|
349
|
+
def shukumei
|
350
|
+
s = []
|
351
|
+
t = kuubou # 天中殺 0:上段, 1:下段
|
352
|
+
k = kanshi.map {|v| v[1] } # 日,月,年柱の干支
|
353
|
+
if t[0].include? k[2]
|
354
|
+
s += ["生年中殺"]
|
355
|
+
end
|
356
|
+
if t[0].include? k[1]
|
357
|
+
s += ["生月中殺"]
|
358
|
+
end
|
359
|
+
if t[1].include? k[0]
|
360
|
+
s += ["生日中殺"]
|
361
|
+
end
|
362
|
+
f = false
|
363
|
+
f = true if kanshi_as_number.include? 11 #甲戌
|
364
|
+
f = true if kanshi_as_number.include? 12 #乙亥
|
365
|
+
s += ["日座中殺"] if f
|
366
|
+
return s
|
367
|
+
end
|
368
|
+
|
369
|
+
def equivalent_kanshi(only_jikkan=false)
|
370
|
+
if only_jikkan
|
371
|
+
k = kanshi.map {|v| v[0] } # 日,月,年柱の十干
|
372
|
+
else
|
373
|
+
k = kanshi
|
374
|
+
end
|
375
|
+
if k[0] == k[1] && k[1] == k[2]
|
376
|
+
return [[0,1],[0,2],[1,2]]
|
377
|
+
elsif k[0] == k[1]
|
378
|
+
return [[0,1]]
|
379
|
+
elsif k[0] == k[2]
|
380
|
+
return [[0,2]]
|
381
|
+
elsif k[1] == k[2]
|
382
|
+
return [[1,2]]
|
383
|
+
else
|
384
|
+
return []
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
def on_distance?(j1,j2,d=6)
|
389
|
+
i = JYUNISHI.index(j1)
|
390
|
+
return j2 == JYUNISHI[(i+d) % 12]
|
391
|
+
end
|
392
|
+
|
393
|
+
# 律音
|
394
|
+
def ricchin
|
395
|
+
# 干支(十干・十二支)が同じ
|
396
|
+
equivalent_kanshi(false)
|
397
|
+
end
|
398
|
+
|
399
|
+
# 納音
|
400
|
+
def nacchin
|
401
|
+
# 十干が同じで十二支が 沖 の関係にある
|
402
|
+
v = []
|
403
|
+
eq = equivalent_kanshi(true)
|
404
|
+
eq.each do |e|
|
405
|
+
k0 = kanshi[e[0]][1]
|
406
|
+
k1 = kanshi[e[1]][1]
|
407
|
+
v += [e] if on_distance?(k0,k1,6)
|
408
|
+
end
|
409
|
+
return v
|
410
|
+
end
|
411
|
+
|
412
|
+
# 宿命大半会
|
413
|
+
def shukumei_daihankai
|
414
|
+
# 十干が同じで十二支が三合会局の関係にある
|
415
|
+
v = []
|
416
|
+
eq = equivalent_kanshi(true)
|
417
|
+
eq.each do |e|
|
418
|
+
k0 = kanshi[e[0]][1]
|
419
|
+
k1 = kanshi[e[1]][1]
|
420
|
+
v += [e] if on_distance?(k0,k1,4)
|
421
|
+
end
|
422
|
+
eq.each do |e|
|
423
|
+
k0 = kanshi[e[0]][1]
|
424
|
+
k1 = kanshi[e[1]][1]
|
425
|
+
v += [e] if on_distance?(k0,k1,8)
|
426
|
+
end
|
427
|
+
return v
|
428
|
+
end
|
429
|
+
|
430
|
+
# 大運 [順行 or 逆行, year] or [nil,nil](if gender is not male nor female)
|
431
|
+
def taiun
|
432
|
+
return [nil,nil] unless ['m','f'].include? @gender
|
433
|
+
k = gogyo_jikkan[2][0]
|
434
|
+
t = @birth_dt[3] * 60 + @birth_dt[4] # 生まれた時間
|
435
|
+
if (@gender == 'm' && k == "+") || (@gender == 'f' && k == '-')
|
436
|
+
order = "順行"
|
437
|
+
d = setsuiri[0] - birth_dt[2]
|
438
|
+
if d > 0 # A 生まれた日が節入り前の場合 (節入り日―誕生日+1)÷3
|
439
|
+
year = ((d + 1) / 3.0).round
|
440
|
+
elsif d == 0 # 節入り日
|
441
|
+
#〈順行〉節入時間「前」=1年 「後」=10年
|
442
|
+
if t <= setsuiri[1]
|
443
|
+
year = 1
|
444
|
+
else
|
445
|
+
year = 10
|
446
|
+
end
|
447
|
+
else # B 生まれた日が節入り後の場合 (誕生月の日数―誕生日+1+翌月の節入り日)÷3
|
448
|
+
s = days_of_current_month - birth_dt[2] + 1 + setsuiri_of_next_month[0]
|
449
|
+
year = (s / 3.0).round
|
450
|
+
end
|
451
|
+
else
|
452
|
+
order = "逆行"
|
453
|
+
if setsuiri?
|
454
|
+
#〈逆行〉節入時間「前」=10年 「後」=1年
|
455
|
+
if t < setsuiri[1]
|
456
|
+
year = 10
|
457
|
+
else
|
458
|
+
year = 1
|
459
|
+
end
|
460
|
+
else
|
461
|
+
year = (zokan_number / 3.0).round
|
462
|
+
end
|
463
|
+
end
|
464
|
+
return [order,year]
|
465
|
+
end
|
466
|
+
|
467
|
+
def taiun_table
|
468
|
+
order,year = taiun
|
469
|
+
return [] if order.nil?
|
470
|
+
d = order == '順行' ? 1 : -1
|
471
|
+
j_day = kanshi[0][0] # 日柱の十干
|
472
|
+
k = kanshi_as_number[1] - 1 # 月柱の干支番号
|
473
|
+
rows = []
|
474
|
+
# [0,1,"癸亥","偏印","死",2]
|
475
|
+
y1, y2 = 0, year
|
476
|
+
8.times do |i|
|
477
|
+
k_month = KANSHI_ARRAY[k] # 月柱の干支
|
478
|
+
t = FourPillarsLogic::tsuhensei(j_day,k_month[0])
|
479
|
+
j = FourPillarsLogic::jyuniunsei(j_day,k_month[1])
|
480
|
+
je = JYUNIUNSEI_ENERGY[j]
|
481
|
+
rows += [[y1,y2,k_month,t,j,je]]
|
482
|
+
if y1 == 0
|
483
|
+
y1 = year
|
484
|
+
else
|
485
|
+
y1 += 10
|
486
|
+
end
|
487
|
+
y2 += 10
|
488
|
+
k += d
|
489
|
+
k = 59 if k < 0
|
490
|
+
k = 0 if k > 59
|
491
|
+
end
|
492
|
+
return rows
|
321
493
|
end
|
322
494
|
end
|
323
495
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yosei Ito
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A class which tells fortune by Four Pillar astrology(四柱推命).
|
14
14
|
email: y-itou@lumber-mill.co.jp
|
@@ -22,7 +22,7 @@ homepage: https://github.com/lumbermill/four-pillars
|
|
22
22
|
licenses:
|
23
23
|
- MIT
|
24
24
|
metadata: {}
|
25
|
-
post_install_message:
|
25
|
+
post_install_message:
|
26
26
|
rdoc_options: []
|
27
27
|
require_paths:
|
28
28
|
- lib
|
@@ -37,8 +37,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
|
-
rubygems_version: 3.
|
41
|
-
signing_key:
|
40
|
+
rubygems_version: 3.2.15
|
41
|
+
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Four Pillar astrology
|
44
44
|
test_files: []
|