four-pillars 0.1.4 → 0.1.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/four-pillars.rb +56 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fa421d59c6eebe39c91e346319e4a53b026247f619032fdc54b2055bdff7e62
4
- data.tar.gz: 9b9ace6b9c0e25546027f14740f3a60467b41f4ca726d65758b2b2f1b3be8c3b
3
+ metadata.gz: d6eefa515e7dfb952f9bdbe39d8b13c98f7877fe2c199de4f5194a64d39d1a67
4
+ data.tar.gz: 2f7d0f8273fb44a68281e921586fc235f54b8e3ea967d4158ba9a2a0f7638ec9
5
5
  SHA512:
6
- metadata.gz: b43a695cb24b025c39cfc38af7d18d68c500357e0560077a05960feef8abde23d4b019201beb73166879ef82c304c43a0d8c0d531b78c0ad6f2ae02117a46090
7
- data.tar.gz: 932fd3efd6e8d0ac69ed4d3aac0de9a340eed2c8a1a0bc3d8e8cc0961f20a72807fb4e043d718dbcfc11d97f5c2414cc96398098f40ac7743e489cf323a024bd
6
+ metadata.gz: 2d642d0f265a32094ac7c52463cb87262ef3b24618a76aeeff267fb58c734a5a7bd1e54c16968db943e4f8a3617c3521b6ed6117ba6fb2ab23e4b935f5caaee3
7
+ data.tar.gz: 79f754b9f7f38ba34da0038caca8b4b19c70e5b1bf92756ed543d3bffd55a7bf7cfd377caff3d31a87529a91cf502d86e65059dc47581178fb7204aa03e0d04a
data/lib/four-pillars.rb CHANGED
@@ -84,7 +84,7 @@ class FourPillarsLogic
84
84
  end
85
85
  SETSUIRI_HASH, SETSUIRI_LIST = load_setsuiri
86
86
 
87
- # 生年月日時間, 性別(鑑定には使用しない)
87
+ # 生年月日時間, 性別(大運の向きに使用)
88
88
  attr_reader :birth_dt,:gender
89
89
 
90
90
  def initialize(birth_dt,gender)
@@ -115,6 +115,12 @@ class FourPillarsLogic
115
115
  (Date.new(y,m,1) - 1).day
116
116
  end
117
117
 
118
+ # 今月の日数
119
+ def days_of_current_month
120
+ y,m,d,h,i = @birth_dt
121
+ Date.new(y,m,1).next_month.prev_day.day
122
+ end
123
+
118
124
  # 前月の節入日
119
125
  def setsuiri_of_previous_month
120
126
  y,m,d,h,i = @birth_dt
@@ -127,6 +133,18 @@ class FourPillarsLogic
127
133
  SETSUIRI_HASH[y*100+m] || [0,0]
128
134
  end
129
135
 
136
+ # 翌月の節入日
137
+ def setsuiri_of_next_month
138
+ y,m,d,h,i = @birth_dt
139
+ if m == 12
140
+ y += 1
141
+ m = 1
142
+ else
143
+ m += 1
144
+ end
145
+ SETSUIRI_HASH[y*100+m] || [0,0]
146
+ end
147
+
130
148
  # 生年月に対する節入日時を知っているか?
131
149
  # このメソッドがfalseを返す場合、干支、蔵干が仮の節入日で計算されています。
132
150
  def know_setsuiri?
@@ -402,6 +420,43 @@ class FourPillarsLogic
402
420
  end
403
421
  return v
404
422
  end
423
+
424
+ # 大運 [順行 or 逆行, year] or [nil,nil](if gender is not male nor female)
425
+ def taiun
426
+ return [nil,nil] unless ['m','f'].include? @gender
427
+ k = gogyo_jikkan[2][0]
428
+ t = @birth_dt[3] * 60 + @birth_dt[4] # 生まれた時間
429
+ if (@gender == 'm' && k == "+") || (@gender == 'f' && k == '-')
430
+ order = "順行"
431
+ d = setsuiri[0] - birth_dt[2]
432
+ if d > 0 # A 生まれた日が節入り前の場合 (節入り日―誕生日+1)÷3
433
+ year = ((d + 1) / 3.0).round
434
+ elsif d == 0 # 節入り日
435
+ #〈順行〉節入時間「前」=1年 「後」=10年
436
+ if t <= setsuiri[1]
437
+ year = 1
438
+ else
439
+ year = 10
440
+ end
441
+ else # B 生まれた日が節入り後の場合 (誕生月の日数―誕生日+1+翌月の節入り日)÷3
442
+ s = days_of_current_month - birth_dt[2] + 1 + setsuiri_of_next_month[0]
443
+ year = (s / 3.0).round
444
+ end
445
+ else
446
+ order = "逆行"
447
+ if setsuiri?
448
+ #〈逆行〉節入時間「前」=10年 「後」=1年
449
+ if t < setsuiri[1]
450
+ year = 10
451
+ else
452
+ year = 1
453
+ end
454
+ else
455
+ year = (zokan_number / 3.0).round
456
+ end
457
+ end
458
+ return [order,year]
459
+ end
405
460
  end
406
461
 
407
462
  if __FILE__ == $0
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
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosei Ito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-03 00:00:00.000000000 Z
11
+ date: 2021-06-13 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