Class: When::Coordinates::Branch

Inherits:
Residue show all
Defined in:
lib/when_exe/region/residue.rb,
lib/when_exe/region/japanese_residues.rb

Overview

十二支

Constant Summary collapse

Notes =
{
  '大將軍' => %w(           ),
  '大陰'   => %w(           ),

  '歳刑'   => %w(           ),
  ''     => %w(           ),
  ''     => %w(   ),
  '黄幡'   => %w(           ),
  '豹尾'   => %w(           ),
  '歳次'   => %w(玄枵 星紀 析木 大火 壽星 鶉尾 鶉火 鶉首 實沈 大梁 降婁 娵訾),

  '天氣'   => %w(東南 西  西南  西 西北   東北  ),
  '天道'   => %w(艮坤 甲庚 乙辛 巽乾 丙壬 丁癸),
  '人道'   => %w(巽乾 丙壬 丁癸 艮坤 甲庚 乙辛),
  '天徳'   => %w(           ),
  '用時'   => %w(艮巽坤乾 乙丁辛亥 甲丙庚壬),
  '月徳'   => %w(   ),
  '月徳合' => %w(   ),
  '月空'   => %w(   ),
  '三鏡'   => %w(甲丙庚壬坤乾 甲乙丁庚辛癸 乙辛乾坤巽艮 甲丙庚壬乾巽
          乙丙丁辛壬癸 丁癸乾坤巽艮 甲丙庚壬坤艮 甲乙丁庚辛癸
          乙辛乾艮巽坤 甲丙庚壬乾巽 乙丙丁辛壬癸 丁癸坤乾艮巽),
  '土府'   => %w(           ),
  '土公'   => %w(           ),

  '十二直' => %w(  滿         ),
  '三禍'   => %w(           ),
  '下食時' => %w(亥+ 子+ 丑+ 寅+       酉+ 戌+)
}

Constants inherited from Residue

Residue::LabelProperty

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary

Attributes inherited from Residue

#carry, #divisor, #remainder, #units

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Instance Method Summary collapse

Methods inherited from Residue

#%, #&, #+, #-, #<<, #>>, #[], _china, #_enumerator, #_to_hash_value, day_of_week, #difference, #duration, #event, #initialize, mod, #to, #to_m17n, #to_s

Methods included from Parts::Resource

#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, _setup_, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?

Methods included from Parts::Resource::Pool

#[], #[]=, #_pool, #_setup_, #pool_keys

Methods included from Parts::Resource::Synchronize

#synchronize

Constructor Details

This class inherits a constructor from When::Coordinates::Residue

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::Coordinates::Residue

Instance Method Details

#_day_notes(notes = {}, dates = nil, conditions = {}) ⇒ Object

日の十二支で決まる暦注



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/when_exe/region/japanese_residues.rb', line 204

def _day_notes(notes={}, dates=nil, conditions={})

  # 節月
  month = dates.s_date.cal_date[1]
  born  = Notes['三禍'][month-1] + ''

  # 具注暦(元嘉暦以来)
  notes['十二直']   ||= Notes['十二直'][(@remainder-month-1) % 12]
  notes['歸忌'  ]   ||= @remainder == (month % 3) ? '歸忌' : nil
  notes['血忌'  ]   ||= @remainder == [1,7,2,8,3,9,4,10,5,11,6,0][month-1] ? '血忌' : nil
  notes['九坎'  ]   ||= @remainder == [4,1,10,7,3,0,9,6,2,11,8,5][month-1] ? '九坎' : nil
  notes[''    ]   ||= @remainder == (17-month) % 12 ? '厭對' : nil
  notes[''    ]   ||= @remainder == (11-month) % 12 ? ''   : nil
  notes['母倉'  ]   ||= [[0,11],    [0,11],    [5,6], [2,3], [2,3], [5,6],
                  [1,4,7,10],[1,4,7,10],[5,6], [8,9], [8,9], [5,6]][month-1].include?(@remainder) ? '母倉' : nil unless notes['凶会']
  notes['天倉'  ]   ||= @remainder == (3-month) % 12  ? '天倉' : nil

  # 具注暦(大衍暦以来)
  notes['忌遠行']   ||= @remainder == [1,9,5][month % 3]            ? '忌遠行' : nil
  notes['忌夜行']   ||= @remainder == [0,6,5,10,7,4][(month-1) / 2] ? '忌夜行' : nil
  notes['大禍'  ]   ||= @remainder == (month * 7 +  4) % 12 ?  born + '大禍' : nil
  notes['狼藉'  ]   ||= @remainder == (dates.range >= 14 ? ((month-1) % 4) * 3 :                      #  - wikipedia 「天火」におなじ
                                           [0,3,6,6,0,3,9,9,3,3,6,9][month-1]) ?  born + '狼藉' : nil # %w(...酉..午.子...)
  notes['滅門'  ]   ||= @remainder == (month * 7 + 10) % 12 ?  born + '滅門' : nil
  notes['下食時']   ||= @remainder == [7,10,4,2,6,0,8,9,5,11,1,3][month-1] ? Notes['下食時'][month-1] : nil
  notes['下食時']     = dates.range < 11 ? notes['下食時' ].sub(/\+/, '') : nil if /\+/ =~ notes['下食時'].to_s # '+' は貞享改暦以降記さない
  notes['無翹'  ]   ||= @remainder == (12-month) % 12 ? '無翹' : nil
  notes['不弔人']   ||= [4,6].include?(@remainder) ? '不弔人' : nil # 不断
  notes[''    ]   ||= @remainder % 6 == 5 ? '' : nil            # 不断
  unless notes['凶会'] || notes[''] || notes['']
    notes['沐浴']     ||= [0,8,9,11].include?(@remainder) ? '沐浴' : nil
    notes['除手足甲'] ||= {1=>'除手甲', 2=>'除足甲'}[@remainder]
  end
  notes['月煞'  ]   ||= @remainder == [4,1,10,7][month % 4] ? '月煞' : nil

  # 仮名暦
  notes['初午']     ||= @remainder == 6 && dates.o_date.cal_date[1] == 2 && (1..12).include?(dates.o_date.cal_date[2]) ? '初午' : nil
  notes['天火'  ]   ||= @remainder == ((month-1) % 4) * 3 ? '天火' : nil
  notes['地火'  ]   ||= @remainder == (month + 4) % 12 ? '地火' : nil
  notes['人火'  ]   ||= @remainder == [12,0,8,10,12,3,7,6,12,6,9,9][month-1] ? '人火' : nil
  notes['雷火'  ]   ||= @remainder == [12,7,7,5,12,6,6,5,12,11,7,6][month-1] ? '雷火' : nil
  notes['一粒万倍'] ||= [[1,6],[2,9],[0,3],[3,4 ],[5,6 ],[6,9],
                  [0,7],[3,8],[6,9],[9,10],[0,11],[0,3]][month-1].include?(@remainder) ? '一粒万倍' : nil
  notes['金神間日'] ||= @remainder == [1,8,7,9][(month-1) / 3] ? '金神間日' : nil
  notes['十死'    ] ||= @remainder == [1,9,5][month % 3] ? '十死' : nil
  notes['受死'    ] ||= @remainder == [10,4,11,5,0,6,1,7,2,8,3,9][month-1] ? '受死' : nil
  notes['天福'    ] ||= @remainder == [5,2,11,8][month % 4] ? '天福' : nil
  notes['地福'    ] ||= @remainder == [11,8,5,2][month % 4] ? '地福' : nil
  notes['地五福'  ] ||= @remainder == [8,11,2,5][month % 4] ? '地五福' : nil
  notes['三隣亡'  ] ||= @remainder == [6,11,2][month % 3] ? '三隣亡' : nil

  notes
end

#_month_notes(notes = {}, dates = nil, conditions = {}) ⇒ Object

月の十二支で決まる暦注



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/when_exe/region/japanese_residues.rb', line 180

def _month_notes(notes={}, dates=nil, conditions={})
  if dates.range < 2
    notes['天氣']   ||= Notes['天氣'  ][@remainder] + ''
    notes['天道']   ||= Notes['天道'  ][@remainder % 6]
    notes['人道']   ||= Notes['人道'  ][@remainder % 6]
    notes['月破']   ||= Notes[''    ][@remainder]
  else
    notes['天道']   ||= Notes['天氣'  ][@remainder] + ''
  end
  notes['天徳'  ]   ||= Notes['天徳'  ][@remainder]
  notes['月煞'  ]   ||= Notes[''    ][@remainder % 4]
  notes['用時'  ]   ||= Notes['用時'  ][@remainder % 3]
  notes['月徳'  ]   ||= Notes['月徳'  ][@remainder % 4]
  notes['月徳合']   ||= Notes['月徳合'][@remainder % 4]
  notes['月空'  ]   ||= Notes['月空'  ][@remainder % 4]
  notes['三鏡'  ]   ||= Notes['三鏡'  ][@remainder]
  notes['土府'  ]   ||= Notes['土府'  ][@remainder]
  notes['土公'  ]   ||= Notes['土公'  ][@remainder]
  notes
end

#_year_notes(notes = {}, dates = nil, conditions = {}) ⇒ Object

年の十二支で決まる暦注



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/when_exe/region/japanese_residues.rb', line 160

def _year_notes(notes={}, dates=nil, conditions={})
  notes['大將軍']   ||= Notes['大將軍'][@remainder]
  notes['大陰'  ]   ||= Notes['大陰'  ][@remainder]
  notes['歳刑'  ]   ||= Notes['歳刑'  ][@remainder]
  notes['歳破'  ]   ||= Notes[''    ][@remainder]
  notes['歳煞'  ]   ||= Notes[''    ][@remainder % 4]
  notes['黄幡'  ]   ||= Notes['黄幡'  ][@remainder]
  notes['豹尾'  ]   ||= Notes['豹尾'  ][@remainder]
  if dates.range < 2
    notes['天道']   ||= Notes['天道'  ][@remainder % 6]
    notes['人道']   ||= Notes['人道'  ][@remainder % 6]
  else
    notes['歳次']   ||= Notes['歳次'  ][@remainder]
  end
  notes
end