four-pillars 0.1.13 → 0.1.14
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 +58 -26
- 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: c3208005abb1c52cad09b0e9b335a22351553193308d8716b535eedde2ffd9aa
         | 
| 4 | 
            +
              data.tar.gz: 570bf5d0a00163dc68202f42f76d07a7f746f2a54d52c6309e95ca01094dfc7c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c60b16002946f6e495eb72e2abe5230285e4b25b2ed6c5cc784cd26a28c02e70e97d4f66e6918b16b16273650add5c9047a0e2d1181e459e5b689cf142d3300f
         | 
| 7 | 
            +
              data.tar.gz: 5c9f536213509c42325111551d35f3c9aa1e0891fde699ab358c0ee5f464e9e6a215659d62c98a0a6d967ee841d8f11e2ab59b128f7dc78437e6aa561bf8efa2
         | 
    
        data/lib/four-pillars.rb
    CHANGED
    
    | @@ -257,7 +257,7 @@ class FourPillarsLogic | |
| 257 257 | 
             
                zn = zokan_number
         | 
| 258 258 | 
             
                z = []
         | 
| 259 259 | 
             
                kanshi.each do |k|
         | 
| 260 | 
            -
                  j = k | 
| 260 | 
            +
                  j = k&.slice(1) # 十二支
         | 
| 261 261 | 
             
                  if zokan_hash1.keys.include? j
         | 
| 262 262 | 
             
                    z += [zokan_hash1[j]]
         | 
| 263 263 | 
             
                  elsif zokan_hash2.keys.include? j
         | 
| @@ -276,6 +276,8 @@ class FourPillarsLogic | |
| 276 276 | 
             
                    else
         | 
| 277 277 | 
             
                      z += [arr[4]]
         | 
| 278 278 | 
             
                    end
         | 
| 279 | 
            +
                  else # j == nil
         | 
| 280 | 
            +
                    z += [nil]
         | 
| 279 281 | 
             
                  end
         | 
| 280 282 | 
             
                end
         | 
| 281 283 | 
             
                return z
         | 
| @@ -283,14 +285,18 @@ class FourPillarsLogic | |
| 283 285 |  | 
| 284 286 | 
             
              # 通変星(nil,月,年)
         | 
| 285 287 | 
             
              def tsuhensei
         | 
| 288 | 
            +
                o = @with_time ? 1 : 0
         | 
| 289 | 
            +
                m = FourPillarsLogic::tsuhensei(kanshi[o][0],kanshi[o + 1][0])
         | 
| 290 | 
            +
                y = FourPillarsLogic::tsuhensei(kanshi[o][0],kanshi[o + 2][0])
         | 
| 286 291 | 
             
                if @with_time
         | 
| 287 | 
            -
                   | 
| 288 | 
            -
                   | 
| 289 | 
            -
             | 
| 292 | 
            +
                  tk = kanshi[0]&.slice(0)
         | 
| 293 | 
            +
                  if tk.nil?
         | 
| 294 | 
            +
                    t = nil
         | 
| 295 | 
            +
                  else
         | 
| 296 | 
            +
                    t = FourPillarsLogic::tsuhensei(kanshi[o][0],tk)
         | 
| 297 | 
            +
                  end
         | 
| 290 298 | 
             
                  [t,nil,m,y]
         | 
| 291 299 | 
             
                else
         | 
| 292 | 
            -
                  m = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[1][0])
         | 
| 293 | 
            -
                  y = FourPillarsLogic::tsuhensei(kanshi[0][0],kanshi[2][0])
         | 
| 294 300 | 
             
                  [nil,m,y]
         | 
| 295 301 | 
             
                end
         | 
| 296 302 | 
             
              end
         | 
| @@ -309,15 +315,19 @@ class FourPillarsLogic | |
| 309 315 | 
             
                  j_day = jikkan.index(zokan[1])
         | 
| 310 316 | 
             
                  j_month = jikkan.index(zokan[2])
         | 
| 311 317 | 
             
                  j_year = jikkan.index(zokan[3])
         | 
| 312 | 
            -
                   | 
| 313 | 
            -
             | 
| 318 | 
            +
                  if j_time.nil?
         | 
| 319 | 
            +
                    t_time = nil
         | 
| 320 | 
            +
                  else
         | 
| 321 | 
            +
                    t_time = j_time - j
         | 
| 322 | 
            +
                    t_time += 10 if t_time < 0
         | 
| 323 | 
            +
                  end
         | 
| 314 324 | 
             
                  t_day = j_day - j
         | 
| 315 325 | 
             
                  t_day += 10 if t_day < 0
         | 
| 316 326 | 
             
                  t_month = j_month - j
         | 
| 317 327 | 
             
                  t_month += 10 if t_month < 0
         | 
| 318 328 | 
             
                  t_year = j_year - j
         | 
| 319 329 | 
             
                  t_year += 10 if t_year < 0
         | 
| 320 | 
            -
                  [TSUHENSEI[t_time],TSUHENSEI[t_day],TSUHENSEI[t_month],TSUHENSEI[t_year]]
         | 
| 330 | 
            +
                  [(t_time.nil? ? nil : TSUHENSEI[t_time]),TSUHENSEI[t_day],TSUHENSEI[t_month],TSUHENSEI[t_year]]
         | 
| 321 331 | 
             
                else
         | 
| 322 332 | 
             
                  j = JIKKAN.index(kanshi[0][0])
         | 
| 323 333 | 
             
                  if j % 2 == 0 # 陽
         | 
| @@ -346,7 +356,11 @@ class FourPillarsLogic | |
| 346 356 | 
             
                m = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[1 + o][1])
         | 
| 347 357 | 
             
                y = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[2 + o][1])
         | 
| 348 358 | 
             
                return [d,m,y] unless @with_time
         | 
| 349 | 
            -
                 | 
| 359 | 
            +
                if @birth_dt[3].nil? # when hour is nil
         | 
| 360 | 
            +
                  t = nil
         | 
| 361 | 
            +
                else
         | 
| 362 | 
            +
                  t = FourPillarsLogic::jyuniunsei(kanshi[o][0],kanshi[0][1])
         | 
| 363 | 
            +
                end
         | 
| 350 364 | 
             
                [t,d,m,y]
         | 
| 351 365 | 
             
              end
         | 
| 352 366 |  | 
| @@ -363,6 +377,11 @@ class FourPillarsLogic | |
| 363 377 | 
             
                [KUUBOU[k_day],KUUBOU[k_year]]
         | 
| 364 378 | 
             
              end
         | 
| 365 379 |  | 
| 380 | 
            +
              # 日柱のインデックス 時柱を求める場合は1になる
         | 
| 381 | 
            +
              def offset_for_day
         | 
| 382 | 
            +
                @with_time ? 1 : 0
         | 
| 383 | 
            +
              end
         | 
| 384 | 
            +
             | 
| 366 385 | 
             
              # テーブル表示用に配列にして返す (デバッグ用)
         | 
| 367 386 | 
             
              # 0:干支, 1:干支数字, 2:蔵干, 3:通変星, 4:蔵干通変星, 5:十二運星
         | 
| 368 387 | 
             
              # 五行、天中殺、十二運星エネルギーは別途
         | 
| @@ -380,8 +399,13 @@ class FourPillarsLogic | |
| 380 399 | 
             
              def gogyo_jikkan
         | 
| 381 400 | 
             
                arr = []
         | 
| 382 401 | 
             
                kanshi.length.times do |i|
         | 
| 383 | 
            -
                   | 
| 384 | 
            -
                   | 
| 402 | 
            +
                  k = kanshi[i]&.slice(0)
         | 
| 403 | 
            +
                  if k.nil?
         | 
| 404 | 
            +
                    arr += [nil]
         | 
| 405 | 
            +
                  else
         | 
| 406 | 
            +
                    j = JIKKAN.index(k)
         | 
| 407 | 
            +
                    arr += [(j % 2 == 0 ? "+" : "-") + GOGYO[j / 2]]
         | 
| 408 | 
            +
                  end
         | 
| 385 409 | 
             
                end
         | 
| 386 410 | 
             
                return arr
         | 
| 387 411 | 
             
              end
         | 
| @@ -391,8 +415,13 @@ class FourPillarsLogic | |
| 391 415 | 
             
                arr = []
         | 
| 392 416 | 
             
                gogyo_j = ["水","土","木","木","土","火","火","土","金","金","土","水"]
         | 
| 393 417 | 
             
                kanshi.length.times do |i|
         | 
| 394 | 
            -
                   | 
| 395 | 
            -
                   | 
| 418 | 
            +
                  jj = kanshi[i]&.slice(1)
         | 
| 419 | 
            +
                  if jj.nil?
         | 
| 420 | 
            +
                    arr += [nil]
         | 
| 421 | 
            +
                  else
         | 
| 422 | 
            +
                    j = JYUNISHI.index(jj)
         | 
| 423 | 
            +
                    arr += [(j % 2 == 0 ? "+" : "-") + gogyo_j[j]]
         | 
| 424 | 
            +
                  end
         | 
| 396 425 | 
             
                end
         | 
| 397 426 | 
             
                return arr
         | 
| 398 427 | 
             
              end
         | 
| @@ -400,8 +429,8 @@ class FourPillarsLogic | |
| 400 429 | 
             
              # 守護神
         | 
| 401 430 | 
             
              def shugoshin
         | 
| 402 431 | 
             
                # 日柱の十干と月柱の十二支
         | 
| 403 | 
            -
                x = JIKKAN.index(kanshi[0][0])
         | 
| 404 | 
            -
                y = JYUNISHI.index(kanshi[1][1])
         | 
| 432 | 
            +
                x = JIKKAN.index(kanshi[0 + offset_for_day][0])
         | 
| 433 | 
            +
                y = JYUNISHI.index(kanshi[1 + offset_for_day][1])
         | 
| 405 434 | 
             
                SHUGOSHIN[y][x].split("")
         | 
| 406 435 | 
             
              end
         | 
| 407 436 |  | 
| @@ -409,7 +438,9 @@ class FourPillarsLogic | |
| 409 438 | 
             
              def shukumei
         | 
| 410 439 | 
             
                s = []
         | 
| 411 440 | 
             
                t = kuubou # 天中殺 0:上段, 1:下段
         | 
| 412 | 
            -
                 | 
| 441 | 
            +
                ka = kanshi
         | 
| 442 | 
            +
                ka.delete_at(0) if @with_time
         | 
| 443 | 
            +
                k = ka.map {|v| v[1] } # 日,月,年柱の干支
         | 
| 413 444 | 
             
                if t[0].include? k[2]
         | 
| 414 445 | 
             
                  s += ["生年中殺"]
         | 
| 415 446 | 
             
                end
         | 
| @@ -427,10 +458,10 @@ class FourPillarsLogic | |
| 427 458 | 
             
              end
         | 
| 428 459 |  | 
| 429 460 | 
             
              def equivalent_kanshi(only_jikkan=false)
         | 
| 461 | 
            +
                k = kanshi
         | 
| 462 | 
            +
                k.delete_at(0) if @with_time
         | 
| 430 463 | 
             
                if only_jikkan
         | 
| 431 | 
            -
                  k =  | 
| 432 | 
            -
                else
         | 
| 433 | 
            -
                  k = kanshi
         | 
| 464 | 
            +
                  k = k.map {|v| v[0] } # 日,月,年柱の十干
         | 
| 434 465 | 
             
                end
         | 
| 435 466 | 
             
                if k[0] == k[1] && k[1] == k[2]
         | 
| 436 467 | 
             
                  return [[0,1],[0,2],[1,2]]
         | 
| @@ -462,8 +493,8 @@ class FourPillarsLogic | |
| 462 493 | 
             
                v = []
         | 
| 463 494 | 
             
                eq = equivalent_kanshi(true)
         | 
| 464 495 | 
             
                eq.each do |e|
         | 
| 465 | 
            -
                  k0 = kanshi[e[0]][1]
         | 
| 466 | 
            -
                  k1 = kanshi[e[1]][1]
         | 
| 496 | 
            +
                  k0 = kanshi[e[0] + offset_for_day][1]
         | 
| 497 | 
            +
                  k1 = kanshi[e[1] + offset_for_day][1]
         | 
| 467 498 | 
             
                  v += [e] if on_distance?(k0,k1,6)
         | 
| 468 499 | 
             
                end
         | 
| 469 500 | 
             
                return v
         | 
| @@ -475,13 +506,13 @@ class FourPillarsLogic | |
| 475 506 | 
             
                v = []
         | 
| 476 507 | 
             
                eq = equivalent_kanshi(true)
         | 
| 477 508 | 
             
                eq.each do |e|
         | 
| 478 | 
            -
                  k0 = kanshi[e[0]][1]
         | 
| 479 | 
            -
                  k1 = kanshi[e[1]][1]
         | 
| 509 | 
            +
                  k0 = kanshi[e[0] + offset_for_day][1]
         | 
| 510 | 
            +
                  k1 = kanshi[e[1] + offset_for_day][1]
         | 
| 480 511 | 
             
                  v += [e] if on_distance?(k0,k1,4)
         | 
| 481 512 | 
             
                end
         | 
| 482 513 | 
             
                eq.each do |e|
         | 
| 483 | 
            -
                  k0 = kanshi[e[0]][1]
         | 
| 484 | 
            -
                  k1 = kanshi[e[1]][1]
         | 
| 514 | 
            +
                  k0 = kanshi[e[0] + offset_for_day][1]
         | 
| 515 | 
            +
                  k1 = kanshi[e[1] + offset_for_day][1]
         | 
| 485 516 | 
             
                  v += [e] if on_distance?(k0,k1,8)
         | 
| 486 517 | 
             
                end
         | 
| 487 518 | 
             
                return v
         | 
| @@ -491,6 +522,7 @@ class FourPillarsLogic | |
| 491 522 | 
             
              def taiun
         | 
| 492 523 | 
             
                return [nil,nil] unless ['m','f'].include? @gender
         | 
| 493 524 | 
             
                k = gogyo_jikkan[2][0]
         | 
| 525 | 
            +
                # TODO: 時刻不明の場合は?
         | 
| 494 526 | 
             
                t = @birth_dt[3] * 60 + @birth_dt[4] # 生まれた時間
         | 
| 495 527 | 
             
                if (@gender == 'm' && k == "+") || (@gender == 'f' && k == '-')
         | 
| 496 528 | 
             
                  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.14
         | 
| 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-08- | 
| 11 | 
            +
            date: 2024-08-22 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
         |