Class: Zakuro::Calculation::Option::DroppedDate::Location
- Inherits:
-
Object
- Object
- Zakuro::Calculation::Option::DroppedDate::Location
- Defined in:
- lib/zakuro/calculation/option/dropped_date/location.rb
Overview
Location 没日位置
Constant Summary collapse
- IDEAL_YEAR =
Returns 理想上の年日数.
360
Instance Attribute Summary collapse
-
#context ⇒ Context::Context
readonly
暦コンテキスト.
-
#limit ⇒ Cycle::AbstractRemainder
readonly
「有没之気」判定.
-
#remainder_class ⇒ Class
readonly
没余クラス.
-
#solar_term ⇒ Cycle::AbstractSolarTerm
readonly
二十四節気.
- #valid ⇒ True, False readonly
-
#year ⇒ Integer
readonly
年.
Instance Method Summary collapse
-
#exist? ⇒ True, False
没日が存在するか?.
-
#get ⇒ Cycle::AbstractRemainder
「没余」を返す.
-
#initialize(context:, solar_term:) ⇒ Location
constructor
初期化.
-
#invalid? ⇒ True, False
不正か.
Constructor Details
#initialize(context:, solar_term:) ⇒ Location
初期化
38 39 40 41 42 43 44 45 46 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 38 def initialize(context:, solar_term:) parameter = context.resolver.dropped_date_parameter.new @context = context @valid = parameter.valid @limit = parameter.limit @year = parameter.year @remainder_class = parameter.remainder_class @solar_term = solar_term end |
Instance Attribute Details
#context ⇒ Context::Context (readonly)
Returns 暦コンテキスト.
19 20 21 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 19 def context @context end |
#limit ⇒ Cycle::AbstractRemainder (readonly)
Returns 「有没之気」判定.
24 25 26 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 24 def limit @limit end |
#remainder_class ⇒ Class (readonly)
Returns 没余クラス.
30 31 32 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 30 def remainder_class @remainder_class end |
#solar_term ⇒ Cycle::AbstractSolarTerm (readonly)
Returns 二十四節気.
28 29 30 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 28 def solar_term @solar_term end |
#valid ⇒ True, False (readonly)
22 23 24 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 22 def valid @valid end |
#year ⇒ Integer (readonly)
Returns 年.
26 27 28 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 26 def year @year end |
Instance Method Details
#exist? ⇒ True, False
没日が存在するか?
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 64 def exist? remainder = solar_term_remainder return false if remainder.invalid? minute_later = remainder.class.new( day: 0, minute: remainder.minute, second: remainder.second ) minute_later >= limit end |
#get ⇒ Cycle::AbstractRemainder
「没余」を返す
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 80 def get # 1. 二十四節気の大余小余を取り出す remainder = solar_term_remainder # p "remainder: #{remainder.format(form: '%d-%d.%.5f')}" # 2. 小余360、秒45(360/8)で乗算する total = multiple_ideal_year(remainder: remainder) # p "total: #{total}" # 3. 上記2と章歳(3068055)の差を求める diff = (year - total).abs # p "year: #{year}" # p "diff: #{diff}" # 4. 上記3を通余で徐算する result = remainder_class.new(total: diff) # p "result: #{result.format(form: '%d-%d.%.5f')}" # 5. 上記4の商と上記1の大余が没日大余、余りが小余(没余) day = remainder_class.new(day: remainder.day, minute: 0, second: 0) day.add(result) end |
#invalid? ⇒ True, False
不正か
54 55 56 |
# File 'lib/zakuro/calculation/option/dropped_date/location.rb', line 54 def invalid? !@valid end |