Class: When::Coordinates::StemBranch

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

Overview

六十干支

Constant Summary

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

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, #_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, #next, #parent, #prev, #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

日の六十干支で決まる暦注



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/when_exe/region/japanese/residues.rb', line 318

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

  year, month = dates.s_date.cal_date

  # 具注暦(元嘉暦以来)
  notes['納音']     ||= Rules['納音'][@remainder / 2]
  notes['日遊']     ||= dates.range < 2 ? Rules['日遊'][@remainder] :
                        [4,5,14,15,24,25,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,54,55].include?(@remainder) ? '' : nil
  notes['天赦']     ||= @remainder == [14,30,44,00][(month-1)/3] ? '天赦' : nil

  #   宣明暦以前は節月、貞享暦以後は暦月
# m  = dates.range < 11 ? month : (dates.m_date.cal_date[1] * 1)
  m  = month
  #   凶会日
  kue = Rules['凶会'][m-1][@remainder]
  #   貞享暦で廃止された凶会日を除外
  kue = dates.range < 11 ? kue.sub(/\+/, '') : nil if /\+/ =~ kue
  notes['凶会'] = kue

  #   凶会日に省略される吉日
  _notes_without_kue(notes, month, dates.range < 2 ? '' : '大歳', conditions) unless notes['凶会']

  # 具注暦(大衍暦以来)
  notes['天一']     ||= begin
    note = Rules['天一'][@remainder]
    dates.range >= 15 ?  note.dup.sub!(/天上始/, '天上') :
    dates.range >= 11 ?  note : note.dup.sub!(//, '')
  end
  notes['土公']     ||= Rules['土公'][@remainder]
  notes['五墓']     ||= [4,22,28,31,37].include?(@remainder) ? '五墓' : nil
  notes[''  ]     ||= [6,12,14,15,17,19,20,21,23,28,49,58].include?(@remainder) ? '' : nil

  #   節年に依存する暦注
  div, mod = @remainder.divmod(12)
  base_dir = Rules[''][year % 12]
  move_dir = Rules[''][div]
  unless base_dir == move_dir
	event  = '' + move_dir if mod == 0
	event  = '' + base_dir if mod == 5
  end
  notes['大將軍']   ||= event
  notes['歳下食']   ||= @remainder == [33,22,47,36,13,26,3,28,53,42,43,56][year % 12] ? '歳下食'  : nil

  #   節月に依存する暦注
  notes['天間']     ||= (@remainder % 30) == [23,0,1,2,3,22][(month-1) % 6] ? '天間' : nil
  notes['八龍']     ||= (month-1) / 3 == 0 && [ 0,11].include?(@remainder)  ? '八龍' : nil
  notes['七鳥']     ||= (month-1) / 3 == 1 && [12,23].include?(@remainder)  ? '七鳥' : nil
  notes['九虎']     ||= (month-1) / 3 == 2 && [36,47].include?(@remainder)  ? '九虎' : nil
  notes['六蛇']     ||= (month-1) / 3 == 3 && [48,59].include?(@remainder)  ? '六蛇' : nil

  #   宣明暦以前は節月、貞享暦以後は暦月?
  notes['三寶吉'], notes['神吉'], notes['雑事吉'], notes['小字注'], kana = Rules['吉事注'][m-1][@remainder]
  if conditions[:kana]
    if kana && dates.m_date.ceil(YEAR,MONTH).prev != dates.m_date # 最後の月以外は年末行事を削除する
      kana = kana.dup
      kana.sub!(/すゝはらひ\s?/, '')
      kana.sub!(/正月ことはしめ\s?/, '')
      kana.strip!
      kana = nil if kana == ''
    end
    notes['小字注']   = kana
    notes['神吉']     = '(神吉)' if notes['神吉'] && Rules['神吉'][@remainder][12-month] == 0
  end

  # 仮名暦
# notes['大明']     ||= [5,6,7,8,9,13,15,18,20,23,28,31,38,40,41,42,43,45,46,47,52,54,55,56,57].include?(@remainder) ? '大明' : nil
  notes['大明']     ||= [    7,8,9,13,15,18,20,23,28,31,38,40,41,42,   45,46,47,52,   55,56,57].include?(@remainder) ? '大明' : nil
  unless notes['金神遊行']
    div, mod   = @remainder.divmod(12)
    note       = (2..6).include?(mod) ? '平素' + Rules['平素遊行'][div] : ''
    range, dir = Rules['四季遊行'][(month-1) / 3]
    note      += range.include?(@remainder) ? '四季' + dir : ''
    notes['金神遊行'] = note == '' ? nil : note
  end
  notes['甲子待']   ||= @remainder == 0  ? '甲子待' : nil
  notes['己巳'  ]   ||= @remainder == 5  ? '己巳'   : nil
  notes['庚申待']   ||= @remainder == 56 ? '庚申待' : nil
  if dates.range >= 14
    notes['犯土']   ||= {6 =>'大犯土始', 14=>'小犯土始'}[@remainder]
  else
    notes['犯土']   ||= [7,8,9,10,11].include?(@remainder)    ? '大犯土' : {6 =>'大犯土始', 12=>'大犯土終', 13=>'犯土間日'}[@remainder]
    notes['犯土']   ||= [15,16,17,18,19].include?(@remainder) ? '小犯土' : {14=>'小犯土始', 20=>'小犯土終'}[@remainder]
  end
  notes['十方暮']   ||= [21,22,23,24,25,26,27,28].include?(@remainder) ? '十方暮' : {20=>'十方暮始', 29=>'十方暮終'}[@remainder]
  unless notes['八專']
    note = Rules['八專'][@remainder]
    note = note.sub('','') if note && (9..10).include?(dates.range)
    notes['八專'] = note
  end
  notes['八專間日'] ||= [49,52,54,58].include?(@remainder) ? '八專間日' : nil
end

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

月の六十干支で決まる暦注



310
311
312
313
# File 'lib/when_exe/region/japanese/residues.rb', line 310

def _month_notes(notes={}, dates=nil, conditions={})
  notes['月建']     ||= self
  notes
end

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

年の六十干支で決まる暦注



298
299
300
301
302
303
304
305
# File 'lib/when_exe/region/japanese/residues.rb', line 298

def _year_notes(notes={}, dates=nil, conditions={})
  unless dates.range < 2
    notes['大歳壇'] ||= '' + Rules['大歳壇干'][(@remainder / 2) % 5] + '' + Rules['大歳壇支'][@remainder % 12]
  end
  notes['納音']     ||= Rules['納音'][@remainder / 2]
  notes['大歳']     ||= self
  notes
end