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

Rules =
{
  '大將軍' => %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::HashProperty, Residue::LabelProperty

Constants included from Parts::Resource

Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIDecode, Parts::Resource::IRIDecodeTable, Parts::Resource::IRIEncode, Parts::Resource::IRIEncodeTable, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty

Constants included from Namespace

Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD

Instance Attribute Summary

Attributes inherited from Residue

#carry, #divisor, #remainder, #shifted, #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, #_column_for_week_included, _day_of_week, #_enumerator, #_range_for_week_included, day_of_week, #difference, #duration, #event, #initialize, mod, #to, #to_m17n, #to_s

Methods included from Parts::Resource

#[], #^, _abbreviation_to_iri, _decode, _encode, _extract_prefix, _instance, _instantiate, _parse, _path_with_prefix, _replace_tags, _setup_, _setup_info, _simplify_path, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir

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

日の十二支で決まる暦注



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/when_exe/region/japanese/residues.rb', line 234

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

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

  # 具注暦(元嘉暦以来)
  notes['十二直']   ||= Rules['十二直'][(@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
  unless notes['九坎'] && notes['小字注']
    notes['九坎'  ]   = @remainder == [4,1,10,7,3,0,9,6,2,11,8,5][month-1] ? '九坎' : nil
  end
  notes[''    ]   ||= @remainder == (17-month) % 12 ? '厭對' : nil
  notes[''    ]   ||= @remainder == (11-month) % 12 ? ''   : nil
  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 == (conditions[:kana] ? ((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] ? Rules['下食時'][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
  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['金性']     ||= @remainder == 3 && month == 2  && dates.s_date.cal_date[0] % 12 == 7 &&
                                         (1..12).include?(dates.s_date.cal_date[2]) ? '金性' : nil

  notes
end

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

月の十二支で決まる暦注



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/when_exe/region/japanese/residues.rb', line 210

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

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

年の十二支で決まる暦注



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/when_exe/region/japanese/residues.rb', line 190

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