class Zakuro::Calculation::Monthly::Month
Month
月情報
Attributes
@return [Context] 暦コンテキスト
@return [FirstDay] 月初日(朔日)
@return [MonthLabel] 月表示名
@return [Array<SolarTerm>] 二十四節気
Public Class Methods
初期化
@param [Context] context 暦コンテキスト @param [MonthLabel] month_label
月表示名 @param [FirstDay] first_day
月初日(朔日) @param [Array<SolarTerm>] solar_terms
二十四節気
# File lib/zakuro/calculation/monthly/month.rb, line 33 def initialize(context:, month_label: MonthLabel.new, first_day: FirstDay.new, solar_terms: []) @context = context @month_label = month_label @first_day = first_day @solar_terms = solar_terms end
Public Instance Methods
二十四節気を追加する
@param [SolarTerm] term 二十四節気
# File lib/zakuro/calculation/monthly/month.rb, line 169 def add_term(term:) @solar_terms.push(term) end
月の日数を返す
@return [Integer] 日数
# File lib/zakuro/calculation/monthly/month.rb, line 83 def days @month_label.days end
月の名前(大小)を返す
@return [String] 月の名前(大小)
# File lib/zakuro/calculation/monthly/month.rb, line 92 def days_name @month_label.days_name end
二十四節気が未設定かどうかを検証する
@return [True] 設定なし @return [False] 設定あり
# File lib/zakuro/calculation/monthly/month.rb, line 134 def empty_solar_term? @solar_terms.empty? end
中気なしは閏月とする
# File lib/zakuro/calculation/monthly/month.rb, line 44 def eval_leaped leaped = even_term.invalid? @month_label = MonthLabel.new(number: number, is_many_days: many_days?, leaped: leaped) end
次月の大余から月の日数を定める
@param [Integer] next_month_day 次月の大余
# File lib/zakuro/calculation/monthly/month.rb, line 120 def eval_many_days(next_month_day:) is_many_days = remainder.same_remainder_divided_by_ten?(other: next_month_day) @month_label = MonthLabel.new( number: number, is_many_days: is_many_days, leaped: leaped? ) end
中気を返す
@return [SolarTerm] 中気
# File lib/zakuro/calculation/monthly/month.rb, line 143 def even_term @solar_terms.each do |term| return term if term.index.even? end context.resolver.solar_term.new end
閏を返す
@return [True] 閏月 @return [False] 平月
# File lib/zakuro/calculation/monthly/month.rb, line 111 def leaped? @month_label.leaped end
月の大小を返す
@return [True] 大の月(30日) @return [False] 小の月(29日)
# File lib/zakuro/calculation/monthly/month.rb, line 74 def many_days? @month_label.is_many_days end
月を返す
@return [Integer] 月(xx月のxx)
# File lib/zakuro/calculation/monthly/month.rb, line 101 def number @month_label.number end
節気を返す
@return [SolarTerm] 節気
# File lib/zakuro/calculation/monthly/month.rb, line 156 def odd_term @solar_terms.each do |term| return term if term.index.odd? end context.resolver.solar_term.new end
月初日の大余小余を返す
@return [Remainder] 大余小余
# File lib/zakuro/calculation/monthly/month.rb, line 64 def remainder @first_day.remainder end
同一の月情報かを検証する
@param [Month] other 他の月情報
@return [True] 同一の月 @return [False] 異なる月
# File lib/zakuro/calculation/monthly/month.rb, line 181 def same?(other:) number == other.number && leaped? == other.leaped? end
月初日の西暦日を返す
@return [Western::Calendar] 西暦日
# File lib/zakuro/calculation/monthly/month.rb, line 55 def western_date @first_day.western_date end