Class: When::Coordinates::Kyusei

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::LabelProperty

Constants included from Parts::Resource

Parts::Resource::ConstList, Parts::Resource::ConstTypes, 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

Class 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

Class Method Details

.day(date, s_terms) ⇒ Integer

日の九星のインデックス

Parameters:

Returns:

  • (Integer)

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/when_exe/region/japanese/residues.rb', line 47

def day(date, s_terms)
  date = When.when?(date.to_cal_date.to_s, {:frame=>date.frame, :clock=>date.frame.time_basis})

  [-90,-270].each do |deg|
    prev   = s_terms.term(date, [deg,180])                     # 直前の冬至または夏至
    sign   = s_terms.position(prev)[0] == 270 ? -1 : +1        # 陽遁か?(冬至:-1, 夏至:+1)
    base   = prev.to_i                                         # 当該の冬至または夏至のユリウス日
    kanshi = (base + 17) % 60 - 28                             # 最も近い甲子との日数差
    base  -= kanshi                                            # 当該陰陽遁の始め
    delta  = date.to_i - base                                  # 始めからの日数
    if (kanshi>=29 ? 30 : 0)<= delta # 区間に入るかの確認(甲午の前後1日以内は甲午折り返し)
      delta = 8 - delta if sign < 0
      return delta % 9
    end
 end
 raise ArgumentError, "can't find any solstice."
end

.month(m) ⇒ Integer

月の九星のインデックス

Parameters:

  • m (Integer)

    通月

Returns:

  • (Integer)


35
36
37
# File 'lib/when_exe/region/japanese/residues.rb', line 35

def month(m)
	(m + 2) % 9
end

.year(y) ⇒ Integer

年の九星のインデックス

Parameters:

  • y (Integer)

    西暦の年数

Returns:

  • (Integer)


24
25
26
# File 'lib/when_exe/region/japanese/residues.rb', line 24

def year(y)
	(y + 2) % 9
end