four-pillars 0.1.12 → 0.1.13
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 +88 -33
- 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: 41fdb5b30e28ee0b2b8be1d7bc0cc58dbe672f035a268d384e4398d6a6cbd760
|
4
|
+
data.tar.gz: f02566969d22fce3073674a84ac6e3cace539b85de464bf8aa1d56b014b0f91f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8de4a9a086a69ffbb9f64ebf85b5cda0181b62e47740aebb7ae698a56e7f88af3fde518d95d4d70ef7cccc53347f822d67ce5821924015480e5745e63749b159
|
7
|
+
data.tar.gz: 24f4212abf99ee7d10c34dae35f41f196097a5fb00f829118e372abb8318e2b15438a4a9f59f43c5ebb6ca3442413b449371ac84ffd8dbd6350fc9ed39efbb99
|
data/lib/four-pillars.rb
CHANGED
@@ -118,12 +118,17 @@ class FourPillarsLogic
|
|
118
118
|
# 生年月日時間, 性別(大運の向きに使用)
|
119
119
|
attr_reader :birth_dt, :gender
|
120
120
|
|
121
|
-
def initialize(birth_dt,gender)
|
122
|
-
@birth_dt = birth_dt.map {|v| v.to_i }
|
121
|
+
def initialize(birth_dt,gender,with_time:false)
|
122
|
+
@birth_dt = birth_dt.map {|v| v.nil? ? nil : v.to_i }
|
123
123
|
@gender = gender
|
124
|
+
@with_time = with_time
|
124
125
|
raise "Incorrect birth date: #{birth_dt}" if @birth_dt.count != 5
|
125
126
|
raise "Gender must be m,f or o(other): #{gender}" unless ['o','m','f'].include? @gender
|
126
127
|
raise "Year must be larger than 1863" if @birth_dt[0] < 1864
|
128
|
+
h = @birth_dt[3]
|
129
|
+
if !h.nil? && (h < 0 || h > 23)
|
130
|
+
raise "Invalid hour: #{birth_dt}"
|
131
|
+
end
|
127
132
|
end
|
128
133
|
|
129
134
|
# 生年月日と性別
|
@@ -137,7 +142,12 @@ class FourPillarsLogic
|
|
137
142
|
else
|
138
143
|
g = ""
|
139
144
|
end
|
140
|
-
|
145
|
+
if h.nil? || i.nil?
|
146
|
+
t = ""
|
147
|
+
else
|
148
|
+
t = "#{h}時#{i}分"
|
149
|
+
end
|
150
|
+
"#{y}年#{m}月#{d}日#{t}生 #{g}"
|
141
151
|
end
|
142
152
|
|
143
153
|
# 前月の日数
|
@@ -196,7 +206,8 @@ class FourPillarsLogic
|
|
196
206
|
setsuiri[0] == d
|
197
207
|
end
|
198
208
|
|
199
|
-
# 干支(日,月,年)
|
209
|
+
# 干支((時,)日,月,年)
|
210
|
+
# with_time=trueの時、時柱を含め長さ4の配列を返す
|
200
211
|
def kanshi
|
201
212
|
y,m,d,h,i = @birth_dt
|
202
213
|
sd, st = setsuiri
|
@@ -206,7 +217,17 @@ class FourPillarsLogic
|
|
206
217
|
md -= 1 if d < sd || (d == sd && h*60+i < st)
|
207
218
|
dd = Date.new(y,m,d) - Date.new(1863,12,31) # 1923.10.18 = 甲子
|
208
219
|
|
209
|
-
return [KANSHI_ARRAY[dd % 60],KANSHI_ARRAY[md % 60],KANSHI_ARRAY[yd % 60]]
|
220
|
+
return [KANSHI_ARRAY[dd % 60],KANSHI_ARRAY[md % 60],KANSHI_ARRAY[yd % 60]] unless @with_time
|
221
|
+
|
222
|
+
dp = KANSHI_ARRAY[dd % 60] # 日柱
|
223
|
+
if h.nil?
|
224
|
+
tp = nil
|
225
|
+
else
|
226
|
+
jyunishi_idx = h == 23 ? 0 : ((h + 1) / 2)
|
227
|
+
jikkan_idx = ((JIKKAN.index(dp[0]) % 5) * 2 + jyunishi_idx) % 10
|
228
|
+
tp = JIKKAN[jikkan_idx] + JYUNISHI[jyunishi_idx]
|
229
|
+
end
|
230
|
+
return [tp,dp,KANSHI_ARRAY[md % 60],KANSHI_ARRAY[yd % 60]]
|
210
231
|
end
|
211
232
|
|
212
233
|
# 干支(数字)
|
@@ -262,49 +283,83 @@ class FourPillarsLogic
|
|
262
283
|
|
263
284
|
# 通変星(nil,月,年)
|
264
285
|
def tsuhensei
|
265
|
-
|
266
|
-
|
267
|
-
|
286
|
+
if @with_time
|
287
|
+
m = FourPillarsLogic::tsuhensei(kanshi[1][0],kanshi[2][0])
|
288
|
+
y = FourPillarsLogic::tsuhensei(kanshi[1][0],kanshi[3][0])
|
289
|
+
t = FourPillarsLogic::tsuhensei(kanshi[1][0],kanshi[0][0])
|
290
|
+
[t,nil,m,y]
|
291
|
+
else
|
292
|
+
m = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[1][0])
|
293
|
+
y = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[2][0])
|
294
|
+
[nil,m,y]
|
295
|
+
end
|
268
296
|
end
|
269
297
|
|
270
298
|
# 蔵干通変星
|
271
299
|
def zokan_tsuhensei
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
300
|
+
if @with_time
|
301
|
+
j = JIKKAN.index(kanshi[1][0])
|
302
|
+
if j % 2 == 0 # 陽
|
303
|
+
jikkan = JIKKAN
|
304
|
+
else # 陰
|
305
|
+
jikkan = JIKKAN_IN
|
306
|
+
end
|
307
|
+
j = jikkan.index(kanshi[1][0])
|
308
|
+
j_time = jikkan.index(zokan[0])
|
309
|
+
j_day = jikkan.index(zokan[1])
|
310
|
+
j_month = jikkan.index(zokan[2])
|
311
|
+
j_year = jikkan.index(zokan[3])
|
312
|
+
t_time = j_time - j
|
313
|
+
t_time += 10 if t_time < 0
|
314
|
+
t_day = j_day - j
|
315
|
+
t_day += 10 if t_day < 0
|
316
|
+
t_month = j_month - j
|
317
|
+
t_month += 10 if t_month < 0
|
318
|
+
t_year = j_year - j
|
319
|
+
t_year += 10 if t_year < 0
|
320
|
+
[TSUHENSEI[t_time],TSUHENSEI[t_day],TSUHENSEI[t_month],TSUHENSEI[t_year]]
|
321
|
+
else
|
322
|
+
j = JIKKAN.index(kanshi[0][0])
|
323
|
+
if j % 2 == 0 # 陽
|
324
|
+
jikkan = JIKKAN
|
325
|
+
else # 陰
|
326
|
+
jikkan = JIKKAN_IN
|
327
|
+
end
|
328
|
+
j = jikkan.index(kanshi[0][0])
|
329
|
+
j_day = jikkan.index(zokan[0])
|
330
|
+
j_month = jikkan.index(zokan[1])
|
331
|
+
j_year = jikkan.index(zokan[2])
|
332
|
+
t_day = j_day - j
|
333
|
+
t_day += 10 if t_day < 0
|
334
|
+
t_month = j_month - j
|
335
|
+
t_month += 10 if t_month < 0
|
336
|
+
t_year = j_year - j
|
337
|
+
t_year += 10 if t_year < 0
|
338
|
+
[TSUHENSEI[t_day],TSUHENSEI[t_month],TSUHENSEI[t_year]]
|
277
339
|
end
|
278
|
-
j = jikkan.index(kanshi[0][0])
|
279
|
-
j_day = jikkan.index(zokan[0])
|
280
|
-
j_month = jikkan.index(zokan[1])
|
281
|
-
j_year = jikkan.index(zokan[2])
|
282
|
-
t_day = j_day - j
|
283
|
-
t_day += 10 if t_day < 0
|
284
|
-
t_month = j_month - j
|
285
|
-
t_month += 10 if t_month < 0
|
286
|
-
t_year = j_year - j
|
287
|
-
t_year += 10 if t_year < 0
|
288
|
-
[TSUHENSEI[t_day],TSUHENSEI[t_month],TSUHENSEI[t_year]]
|
289
340
|
end
|
290
341
|
|
291
342
|
# 十二運星
|
292
343
|
def jyuniunsei
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
[
|
344
|
+
o = @with_time ? 1 : 0
|
345
|
+
d = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[0 + o][1])
|
346
|
+
m = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[1 + o][1])
|
347
|
+
y = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[2 + o][1])
|
348
|
+
return [d,m,y] unless @with_time
|
349
|
+
t = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[0][1])
|
350
|
+
[t,d,m,y]
|
297
351
|
end
|
298
352
|
|
299
|
-
# 十二運星エネルギー
|
353
|
+
# 十二運星エネルギー 時中は使わない?
|
300
354
|
def jyuniunsei_energy
|
301
355
|
jyuniunsei.map {|v| JYUNIUNSEI_ENERGY[v] }
|
302
356
|
end
|
303
357
|
|
304
358
|
# 空亡 = 天中殺
|
305
359
|
def kuubou
|
306
|
-
|
307
|
-
|
360
|
+
o = @with_time ? 1 : 0
|
361
|
+
k_day = (kanshi_as_number[0 + o] - 1) / 10
|
362
|
+
k_year = (kanshi_as_number[2 + o] - 1) / 10
|
308
363
|
[KUUBOU[k_day],KUUBOU[k_year]]
|
309
364
|
end
|
310
365
|
|
@@ -324,7 +379,7 @@ class FourPillarsLogic
|
|
324
379
|
# 五行(十干)
|
325
380
|
def gogyo_jikkan
|
326
381
|
arr = []
|
327
|
-
|
382
|
+
kanshi.length.times do |i|
|
328
383
|
j = JIKKAN.index(kanshi[i][0])
|
329
384
|
arr += [(j % 2 == 0 ? "+" : "-") + GOGYO[j / 2]]
|
330
385
|
end
|
@@ -335,7 +390,7 @@ class FourPillarsLogic
|
|
335
390
|
def gogyo_jyunishi
|
336
391
|
arr = []
|
337
392
|
gogyo_j = ["水","土","木","木","土","火","火","土","金","金","土","水"]
|
338
|
-
|
393
|
+
kanshi.length.times do |i|
|
339
394
|
j = JYUNISHI.index(kanshi[i][1])
|
340
395
|
arr += [(j % 2 == 0 ? "+" : "-") + gogyo_j[j]]
|
341
396
|
end
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yosei Ito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-20 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.
|
40
|
+
rubygems_version: 3.5.16
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Four Pillar astrology
|