four-pillars 0.1.13 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/four-pillars.rb +70 -26
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a123e8b07f965a3e7a7659e3897db368a3a2ab0904845c8a21d4cd25c5cb7845
|
4
|
+
data.tar.gz: 5ceb94b92ad003a66af88df64a6e153b6651c60d7c2bbf8f8ddf929e2fe5e3cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3ea6db851952af8757c94f849aa6ceda15325b47a2adccf2c37d8cef6d132dc0157976356f1fe37d3157cae6f6fb5b004400c68e2a97105507fd0c9c18a0ed4
|
7
|
+
data.tar.gz: 4d1ec6ed3b786bd249304108b62c7907c8053e1c32f42f28300bf426bc6cdf4df0c6eb7d9bd33159399d5dd73adfae0cfe9a89678b73797127e9ed01f4357c12
|
data/lib/four-pillars.rb
CHANGED
@@ -51,8 +51,20 @@ class FourPillarsLogic
|
|
51
51
|
end
|
52
52
|
return j
|
53
53
|
end
|
54
|
+
|
55
|
+
# 隠 通変星
|
56
|
+
def self.tushensei_in
|
57
|
+
t = [nil] * 10
|
58
|
+
[0,2,4,6,8].each do |i|
|
59
|
+
t[i] = TSUHENSEI[i+1]
|
60
|
+
t[i+1] = TSUHENSEI[i]
|
61
|
+
end
|
62
|
+
return t
|
63
|
+
end
|
54
64
|
JIKKAN_IN = jikkan_in
|
55
65
|
JYUNISHI_IN = JYUNISHI.reverse
|
66
|
+
TSUHENSEI_IN = tushensei_in
|
67
|
+
JYUNIUNSEI_IN = JYUNIUNSEI.reverse
|
56
68
|
|
57
69
|
# 十二運星エネルギー
|
58
70
|
def self.jyuniunsei_energy
|
@@ -257,7 +269,7 @@ class FourPillarsLogic
|
|
257
269
|
zn = zokan_number
|
258
270
|
z = []
|
259
271
|
kanshi.each do |k|
|
260
|
-
j = k
|
272
|
+
j = k&.slice(1) # 十二支
|
261
273
|
if zokan_hash1.keys.include? j
|
262
274
|
z += [zokan_hash1[j]]
|
263
275
|
elsif zokan_hash2.keys.include? j
|
@@ -276,6 +288,8 @@ class FourPillarsLogic
|
|
276
288
|
else
|
277
289
|
z += [arr[4]]
|
278
290
|
end
|
291
|
+
else # j == nil
|
292
|
+
z += [nil]
|
279
293
|
end
|
280
294
|
end
|
281
295
|
return z
|
@@ -283,14 +297,18 @@ class FourPillarsLogic
|
|
283
297
|
|
284
298
|
# 通変星(nil,月,年)
|
285
299
|
def tsuhensei
|
300
|
+
o = @with_time ? 1 : 0
|
301
|
+
m = FourPillarsLogic::tsuhensei(kanshi[o][0],kanshi[o + 1][0])
|
302
|
+
y = FourPillarsLogic::tsuhensei(kanshi[o][0],kanshi[o + 2][0])
|
286
303
|
if @with_time
|
287
|
-
|
288
|
-
|
289
|
-
|
304
|
+
tk = kanshi[0]&.slice(0)
|
305
|
+
if tk.nil?
|
306
|
+
t = nil
|
307
|
+
else
|
308
|
+
t = FourPillarsLogic::tsuhensei(kanshi[o][0],tk)
|
309
|
+
end
|
290
310
|
[t,nil,m,y]
|
291
311
|
else
|
292
|
-
m = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[1][0])
|
293
|
-
y = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[2][0])
|
294
312
|
[nil,m,y]
|
295
313
|
end
|
296
314
|
end
|
@@ -309,15 +327,19 @@ class FourPillarsLogic
|
|
309
327
|
j_day = jikkan.index(zokan[1])
|
310
328
|
j_month = jikkan.index(zokan[2])
|
311
329
|
j_year = jikkan.index(zokan[3])
|
312
|
-
|
313
|
-
|
330
|
+
if j_time.nil?
|
331
|
+
t_time = nil
|
332
|
+
else
|
333
|
+
t_time = j_time - j
|
334
|
+
t_time += 10 if t_time < 0
|
335
|
+
end
|
314
336
|
t_day = j_day - j
|
315
337
|
t_day += 10 if t_day < 0
|
316
338
|
t_month = j_month - j
|
317
339
|
t_month += 10 if t_month < 0
|
318
340
|
t_year = j_year - j
|
319
341
|
t_year += 10 if t_year < 0
|
320
|
-
[TSUHENSEI[t_time],TSUHENSEI[t_day],TSUHENSEI[t_month],TSUHENSEI[t_year]]
|
342
|
+
[(t_time.nil? ? nil : TSUHENSEI[t_time]),TSUHENSEI[t_day],TSUHENSEI[t_month],TSUHENSEI[t_year]]
|
321
343
|
else
|
322
344
|
j = JIKKAN.index(kanshi[0][0])
|
323
345
|
if j % 2 == 0 # 陽
|
@@ -346,7 +368,11 @@ class FourPillarsLogic
|
|
346
368
|
m = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[1 + o][1])
|
347
369
|
y = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[2 + o][1])
|
348
370
|
return [d,m,y] unless @with_time
|
349
|
-
|
371
|
+
if @birth_dt[3].nil? # when hour is nil
|
372
|
+
t = nil
|
373
|
+
else
|
374
|
+
t = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[0][1])
|
375
|
+
end
|
350
376
|
[t,d,m,y]
|
351
377
|
end
|
352
378
|
|
@@ -363,6 +389,11 @@ class FourPillarsLogic
|
|
363
389
|
[KUUBOU[k_day],KUUBOU[k_year]]
|
364
390
|
end
|
365
391
|
|
392
|
+
# 日柱のインデックス 時柱を求める場合は1になる
|
393
|
+
def offset_for_day
|
394
|
+
@with_time ? 1 : 0
|
395
|
+
end
|
396
|
+
|
366
397
|
# テーブル表示用に配列にして返す (デバッグ用)
|
367
398
|
# 0:干支, 1:干支数字, 2:蔵干, 3:通変星, 4:蔵干通変星, 5:十二運星
|
368
399
|
# 五行、天中殺、十二運星エネルギーは別途
|
@@ -380,8 +411,13 @@ class FourPillarsLogic
|
|
380
411
|
def gogyo_jikkan
|
381
412
|
arr = []
|
382
413
|
kanshi.length.times do |i|
|
383
|
-
|
384
|
-
|
414
|
+
k = kanshi[i]&.slice(0)
|
415
|
+
if k.nil?
|
416
|
+
arr += [nil]
|
417
|
+
else
|
418
|
+
j = JIKKAN.index(k)
|
419
|
+
arr += [(j % 2 == 0 ? "+" : "-") + GOGYO[j / 2]]
|
420
|
+
end
|
385
421
|
end
|
386
422
|
return arr
|
387
423
|
end
|
@@ -391,8 +427,13 @@ class FourPillarsLogic
|
|
391
427
|
arr = []
|
392
428
|
gogyo_j = ["水","土","木","木","土","火","火","土","金","金","土","水"]
|
393
429
|
kanshi.length.times do |i|
|
394
|
-
|
395
|
-
|
430
|
+
jj = kanshi[i]&.slice(1)
|
431
|
+
if jj.nil?
|
432
|
+
arr += [nil]
|
433
|
+
else
|
434
|
+
j = JYUNISHI.index(jj)
|
435
|
+
arr += [(j % 2 == 0 ? "+" : "-") + gogyo_j[j]]
|
436
|
+
end
|
396
437
|
end
|
397
438
|
return arr
|
398
439
|
end
|
@@ -400,8 +441,8 @@ class FourPillarsLogic
|
|
400
441
|
# 守護神
|
401
442
|
def shugoshin
|
402
443
|
# 日柱の十干と月柱の十二支
|
403
|
-
x = JIKKAN.index(kanshi[0][0])
|
404
|
-
y = JYUNISHI.index(kanshi[1][1])
|
444
|
+
x = JIKKAN.index(kanshi[0 + offset_for_day][0])
|
445
|
+
y = JYUNISHI.index(kanshi[1 + offset_for_day][1])
|
405
446
|
SHUGOSHIN[y][x].split("")
|
406
447
|
end
|
407
448
|
|
@@ -409,7 +450,9 @@ class FourPillarsLogic
|
|
409
450
|
def shukumei
|
410
451
|
s = []
|
411
452
|
t = kuubou # 天中殺 0:上段, 1:下段
|
412
|
-
|
453
|
+
ka = kanshi
|
454
|
+
ka.delete_at(0) if @with_time
|
455
|
+
k = ka.map {|v| v[1] } # 日,月,年柱の干支
|
413
456
|
if t[0].include? k[2]
|
414
457
|
s += ["生年中殺"]
|
415
458
|
end
|
@@ -427,10 +470,10 @@ class FourPillarsLogic
|
|
427
470
|
end
|
428
471
|
|
429
472
|
def equivalent_kanshi(only_jikkan=false)
|
473
|
+
k = kanshi
|
474
|
+
k.delete_at(0) if @with_time
|
430
475
|
if only_jikkan
|
431
|
-
k =
|
432
|
-
else
|
433
|
-
k = kanshi
|
476
|
+
k = k.map {|v| v[0] } # 日,月,年柱の十干
|
434
477
|
end
|
435
478
|
if k[0] == k[1] && k[1] == k[2]
|
436
479
|
return [[0,1],[0,2],[1,2]]
|
@@ -462,8 +505,8 @@ class FourPillarsLogic
|
|
462
505
|
v = []
|
463
506
|
eq = equivalent_kanshi(true)
|
464
507
|
eq.each do |e|
|
465
|
-
k0 = kanshi[e[0]][1]
|
466
|
-
k1 = kanshi[e[1]][1]
|
508
|
+
k0 = kanshi[e[0] + offset_for_day][1]
|
509
|
+
k1 = kanshi[e[1] + offset_for_day][1]
|
467
510
|
v += [e] if on_distance?(k0,k1,6)
|
468
511
|
end
|
469
512
|
return v
|
@@ -475,13 +518,13 @@ class FourPillarsLogic
|
|
475
518
|
v = []
|
476
519
|
eq = equivalent_kanshi(true)
|
477
520
|
eq.each do |e|
|
478
|
-
k0 = kanshi[e[0]][1]
|
479
|
-
k1 = kanshi[e[1]][1]
|
521
|
+
k0 = kanshi[e[0] + offset_for_day][1]
|
522
|
+
k1 = kanshi[e[1] + offset_for_day][1]
|
480
523
|
v += [e] if on_distance?(k0,k1,4)
|
481
524
|
end
|
482
525
|
eq.each do |e|
|
483
|
-
k0 = kanshi[e[0]][1]
|
484
|
-
k1 = kanshi[e[1]][1]
|
526
|
+
k0 = kanshi[e[0] + offset_for_day][1]
|
527
|
+
k1 = kanshi[e[1] + offset_for_day][1]
|
485
528
|
v += [e] if on_distance?(k0,k1,8)
|
486
529
|
end
|
487
530
|
return v
|
@@ -491,6 +534,7 @@ class FourPillarsLogic
|
|
491
534
|
def taiun
|
492
535
|
return [nil,nil] unless ['m','f'].include? @gender
|
493
536
|
k = gogyo_jikkan[2][0]
|
537
|
+
# TODO: 時刻不明の場合は?
|
494
538
|
t = @birth_dt[3] * 60 + @birth_dt[4] # 生まれた時間
|
495
539
|
if (@gender == 'm' && k == "+") || (@gender == 'f' && k == '-')
|
496
540
|
order = "順行"
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yosei Ito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-12 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
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
|
-
rubygems_version: 3.5.
|
40
|
+
rubygems_version: 3.5.17
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Four Pillar astrology
|