Class: Zakuro::Calculation::Monthly::Month
- Inherits:
-
Object
- Object
- Zakuro::Calculation::Monthly::Month
- Defined in:
- lib/zakuro/calculation/monthly/month.rb
Overview
Month 月情報
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Context::Context
readonly
暦コンテキスト.
-
#first_day ⇒ FirstDay
readonly
月初日(朔日).
-
#gengou ⇒ Base::Gengou
readonly
元号.
-
#meta ⇒ Meta
readonly
付加情報.
-
#month_label ⇒ MonthLabel
readonly
月表示名.
-
#solar_term_selector ⇒ SolarTermSelector
readonly
二十四節気検索.
Instance Method Summary collapse
-
#add_term(term:) ⇒ Object
二十四節気を追加する.
-
#days ⇒ Integer
月の日数を返す.
-
#days_name ⇒ String
月の名前(大小)を返す.
-
#empty_solar_term? ⇒ True, False
二十四節気が未設定かどうかを検証する.
-
#eval_leaped ⇒ Object
中気なしは閏月とする.
-
#eval_many_days(next_month_day:) ⇒ Object
次月の大余から月の日数を定める.
-
#even_term ⇒ Cycle::AbstractSolarTerm
中気を返す.
-
#include?(date:) ⇒ True, False
範囲内か.
-
#include_by_japan_date?(date:) ⇒ True, False
範囲内か.
-
#initialize(context: Context::Context.new, month_label: MonthLabel.new, first_day: FirstDay.new, solar_terms: [], gengou: Base::Gengou.new, meta: Meta.new) ⇒ Month
constructor
初期化.
-
#invalid? ⇒ True, False
不正か.
-
#last_date ⇒ Western::Calendar
月の終了日を返す.
-
#leaped? ⇒ True, False
閏を返す.
-
#many_days? ⇒ True, False
月の大小を返す.
-
#number ⇒ Integer
月を返す.
-
#odd_term ⇒ Cycle::AbstractSolarTerm
節気を返す.
-
#remainder ⇒ Remainder
月初日の大余小余を返す.
-
#reset_meta(last: Month.new) ⇒ Object
メタ情報を再設定する.
-
#same?(other:) ⇒ True, False
同一の月情報かを検証する.
-
#solar_term_by_day(day:) ⇒ Cycle::AbstractSolarTerm
大余に対応する二十四節気.
-
#solar_terms ⇒ Array<Cyle::AbstractSolarTerm>
二十四節気を返す.
-
#sort_solar_terms ⇒ Object
二十四節気を正しい順序にソートする.
-
#western_date ⇒ Western::Calendar
月初日の西暦日を返す.
Constructor Details
#initialize(context: Context::Context.new, month_label: MonthLabel.new, first_day: FirstDay.new, solar_terms: [], gengou: Base::Gengou.new, meta: Meta.new) ⇒ Month
初期化
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 49 def initialize(context: Context::Context.new, month_label: MonthLabel.new, first_day: FirstDay.new, solar_terms: [], gengou: Base::Gengou.new, meta: Meta.new) @context = context @month_label = month_label @first_day = first_day @solar_term_selector = SolarTermSelector.new(context: context, solar_terms: solar_terms) @gengou = gengou = end |
Instance Attribute Details
#context ⇒ Context::Context (readonly)
Returns 暦コンテキスト.
25 26 27 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 25 def context @context end |
#first_day ⇒ FirstDay (readonly)
Returns 月初日(朔日).
29 30 31 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 29 def first_day @first_day end |
#gengou ⇒ Base::Gengou (readonly)
Returns 元号.
33 34 35 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 33 def gengou @gengou end |
#meta ⇒ Meta (readonly)
Returns 付加情報.
35 36 37 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 35 def end |
#month_label ⇒ MonthLabel (readonly)
Returns 月表示名.
27 28 29 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 27 def month_label @month_label end |
#solar_term_selector ⇒ SolarTermSelector (readonly)
Returns 二十四節気検索.
31 32 33 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 31 def solar_term_selector @solar_term_selector end |
Instance Method Details
#add_term(term:) ⇒ Object
二十四節気を追加する
201 202 203 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 201 def add_term(term:) solar_term_selector.add_term(term: term) end |
#days ⇒ Integer
月の日数を返す
114 115 116 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 114 def days month_label.days end |
#days_name ⇒ String
月の名前(大小)を返す
123 124 125 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 123 def days_name month_label.days_name end |
#empty_solar_term? ⇒ True, False
二十四節気が未設定かどうかを検証する
165 166 167 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 165 def empty_solar_term? solar_term_selector.empty? end |
#eval_leaped ⇒ Object
中気なしは閏月とする
75 76 77 78 79 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 75 def eval_leaped leaped = even_term.invalid? @month_label = MonthLabel.new(number: number, is_many_days: many_days?, leaped: leaped) end |
#eval_many_days(next_month_day:) ⇒ Object
次月の大余から月の日数を定める
151 152 153 154 155 156 157 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 151 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 |
#even_term ⇒ Cycle::AbstractSolarTerm
中気を返す
174 175 176 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 174 def even_term solar_term_selector.even_term end |
#include?(date:) ⇒ True, False
範囲内か
236 237 238 239 240 241 242 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 236 def include?(date:) return false if invalid? DateComparer.include?( date: date, start_date: western_date, last_date: last_date ) end |
#include_by_japan_date?(date:) ⇒ True, False
範囲内か
252 253 254 255 256 257 258 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 252 def include_by_japan_date?(date:) return false if invalid? DateComparer.include_by_japan_date?( date: date, gengou: gengou, month_label: month_label ) end |
#invalid? ⇒ True, False
不正か
68 69 70 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 68 def invalid? context.invalid? end |
#last_date ⇒ Western::Calendar
月の終了日を返す
222 223 224 225 226 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 222 def last_date return Western::Calendar.new if western_date.invalid? western_date.clone + days - 1 end |
#leaped? ⇒ True, False
閏を返す
142 143 144 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 142 def leaped? month_label.leaped end |
#many_days? ⇒ True, False
月の大小を返す
105 106 107 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 105 def many_days? month_label.is_many_days end |
#number ⇒ Integer
月を返す
132 133 134 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 132 def number month_label.number end |
#odd_term ⇒ Cycle::AbstractSolarTerm
節気を返す
183 184 185 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 183 def odd_term solar_term_selector.odd_term end |
#remainder ⇒ Remainder
月初日の大余小余を返す
95 96 97 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 95 def remainder first_day.remainder end |
#reset_meta(last: Month.new) ⇒ Object
メタ情報を再設定する
283 284 285 286 287 288 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 283 def (last: Month.new) = MetaCollector.get( before_month: last, current_month: self ) end |
#same?(other:) ⇒ True, False
同一の月情報かを検証する
213 214 215 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 213 def same?(other:) number == other.number && leaped? == other.leaped? end |
#solar_term_by_day(day:) ⇒ Cycle::AbstractSolarTerm
大余に対応する二十四節気
274 275 276 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 274 def solar_term_by_day(day:) solar_term_selector.solar_term_by_day(day: day, meta: ) end |
#solar_terms ⇒ Array<Cyle::AbstractSolarTerm>
二十四節気を返す
192 193 194 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 192 def solar_terms solar_term_selector.solar_terms end |
#sort_solar_terms ⇒ Object
二十四節気を正しい順序にソートする
263 264 265 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 263 def sort_solar_terms solar_term_selector.sort end |
#western_date ⇒ Western::Calendar
月初日の西暦日を返す
86 87 88 |
# File 'lib/zakuro/calculation/monthly/month.rb', line 86 def western_date first_day.western_date end |