four-pillars 0.1.16 → 0.1.17
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 +19 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af28e0c7492629860cfefa10e408001a09f522f217930e9c6a54a2a2f993631
|
4
|
+
data.tar.gz: ba92cb749d89f4b0af02b00d2b146761e93eb879e6bff81f68dad4a4fbca55dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a17b6e76c63cedf7694ea1e247912245db0ef8ae478cfa5257833b65a8caeeb9896622db31d78f1b8bb4aeb848332d43eae830910c951cd2bda10c57aa66e2ae
|
7
|
+
data.tar.gz: b9db9e123171c3a6afdf5559a0138660652b047f558277769dbe85d91a764d62df13661366a640044b38f4134907806799856fb83cb3dc4737d8c345ea55b611
|
data/lib/four-pillars.rb
CHANGED
@@ -130,15 +130,16 @@ class FourPillarsLogic
|
|
130
130
|
# 生年月日時間, 性別(大運の向きに使用)
|
131
131
|
attr_reader :birth_dt, :gender
|
132
132
|
|
133
|
-
def initialize(birth_dt,gender,with_time:false)
|
134
|
-
@birth_dt = birth_dt.map {|v| v.
|
133
|
+
def initialize(birth_dt,gender,with_time:false,know_time:true)
|
134
|
+
@birth_dt = birth_dt.map {|v| v.to_i } # 時分がnilの場合、0になる
|
135
135
|
@gender = gender
|
136
136
|
@with_time = with_time
|
137
|
+
@know_time = know_time && birth_dt[3] != nil
|
137
138
|
raise "Incorrect birth date: #{birth_dt}" if @birth_dt.count != 5
|
138
139
|
raise "Gender must be m,f or o(other): #{gender}" unless ['o','m','f'].include? @gender
|
139
140
|
raise "Year must be larger than 1863" if @birth_dt[0] < 1864
|
140
141
|
h = @birth_dt[3]
|
141
|
-
if
|
142
|
+
if h < 0 || h > 23
|
142
143
|
raise "Invalid hour: #{birth_dt}"
|
143
144
|
end
|
144
145
|
end
|
@@ -154,10 +155,10 @@ class FourPillarsLogic
|
|
154
155
|
else
|
155
156
|
g = ""
|
156
157
|
end
|
157
|
-
if
|
158
|
-
t = ""
|
159
|
-
else
|
158
|
+
if @know_time
|
160
159
|
t = "#{h}時#{i}分"
|
160
|
+
else
|
161
|
+
t = ""
|
161
162
|
end
|
162
163
|
"#{y}年#{m}月#{d}日#{t}生 #{g}"
|
163
164
|
end
|
@@ -223,6 +224,10 @@ class FourPillarsLogic
|
|
223
224
|
def kanshi
|
224
225
|
y,m,d,h,i = @birth_dt
|
225
226
|
sd, st = setsuiri
|
227
|
+
if d == sd
|
228
|
+
# puts "d=#{d}, h=#{h}, i=#{i}"
|
229
|
+
end
|
230
|
+
|
226
231
|
yd = y - 1864 # (till 1865.02.0?) = 甲子
|
227
232
|
yd -= 1 if m < 2 || (m == 2 && d < sd) || (m == 2 && d == sd && h*60+i < st)
|
228
233
|
md = (y - 1863) * 12 + (m - 12) # (till 1864.01.05) = 甲子
|
@@ -232,12 +237,12 @@ class FourPillarsLogic
|
|
232
237
|
return [KANSHI_ARRAY[dd % 60],KANSHI_ARRAY[md % 60],KANSHI_ARRAY[yd % 60]] unless @with_time
|
233
238
|
|
234
239
|
dp = KANSHI_ARRAY[dd % 60] # 日柱
|
235
|
-
if
|
236
|
-
tp = nil
|
237
|
-
else
|
240
|
+
if @know_time
|
238
241
|
jyunishi_idx = h == 23 ? 0 : ((h + 1) / 2)
|
239
242
|
jikkan_idx = ((JIKKAN.index(dp[0]) % 5) * 2 + jyunishi_idx) % 10
|
240
243
|
tp = JIKKAN[jikkan_idx] + JYUNISHI[jyunishi_idx]
|
244
|
+
else
|
245
|
+
tp = nil
|
241
246
|
end
|
242
247
|
return [tp,dp,KANSHI_ARRAY[md % 60],KANSHI_ARRAY[yd % 60]]
|
243
248
|
end
|
@@ -368,10 +373,10 @@ class FourPillarsLogic
|
|
368
373
|
m = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[1 + o][1])
|
369
374
|
y = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[2 + o][1])
|
370
375
|
return [d,m,y] unless @with_time
|
371
|
-
if @
|
372
|
-
t = nil
|
373
|
-
else
|
376
|
+
if @know_time
|
374
377
|
t = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[0][1])
|
378
|
+
else
|
379
|
+
t = nil
|
375
380
|
end
|
376
381
|
[t,d,m,y]
|
377
382
|
end
|
@@ -533,9 +538,8 @@ class FourPillarsLogic
|
|
533
538
|
# 大運 [順行 or 逆行, year] or [nil,nil](if gender is not male nor female)
|
534
539
|
def taiun
|
535
540
|
return [nil,nil] unless ['m','f'].include? @gender
|
536
|
-
k = gogyo_jikkan[2][0]
|
537
|
-
#
|
538
|
-
t = @birth_dt[3] * 60 + @birth_dt[4] # 生まれた時間
|
541
|
+
k = gogyo_jikkan[2 + offset_for_day][0]
|
542
|
+
t = @birth_dt[3] * 60 + @birth_dt[4].to_i # 生まれた時間
|
539
543
|
if (@gender == 'm' && k == "+") || (@gender == 'f' && k == '-')
|
540
544
|
order = "順行"
|
541
545
|
d = setsuiri[0] - birth_dt[2]
|
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.17
|
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-09-
|
11
|
+
date: 2024-09-25 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
|