Class: When::CalendarTypes::CalendarNote::LuniSolarPositions

Inherits:
When::CalendarTypes::CalendarNote show all
Defined in:
lib/when_exe/calendartypes.rb

Overview

太陽と月の位置によるイベント

Direct Known Subclasses

LunarPhases, SolarTerms

Constant Summary

Constants inherited from When::CalendarTypes::CalendarNote

BahaiNotes, ChineseNotes, DefaultNotes, JavaneseNotes, JulianDayNotes, MayanNotes, YiNotes

Constants included from Parts::Resource

Parts::Resource::LabelProperty, Parts::Resource::Prefix, Parts::Resource::PrefixIndex, Parts::Resource::PrefixKeys, Parts::Resource::PrefixValues

Instance Attribute Summary collapse

Attributes inherited from When::CalendarTypes::CalendarNote

#event

Attributes inherited from TM::ReferenceSystem

#domain, #domain_of_validity

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

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

Instance Method Summary collapse

Methods inherited from When::CalendarTypes::CalendarNote

#copy, #day, #duration, #enum_for, #include?, #month, #note?, #notes, #year

Methods inherited from TM::ReferenceSystem

#name

Methods inherited from BasicTypes::Object

#tap

Methods included from Parts::Resource

#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, #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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::Parts::Resource

Instance Attribute Details

#deltaNumeric (readonly)

enumerator の周期

Returns:



1586
1587
1588
# File 'lib/when_exe/calendartypes.rb', line 1586

def delta
  @delta
end

#denNumeric (readonly)

座標の分母

Returns:



1574
1575
1576
# File 'lib/when_exe/calendartypes.rb', line 1574

def den
  @den
end

#formulaWhen::Ephemeris::Formula (readonly)

計算アルゴリズム



1580
1581
1582
# File 'lib/when_exe/calendartypes.rb', line 1580

def formula
  @formula
end

#marginNumeric (readonly)

没滅計算用の補正

Returns:



1592
1593
1594
# File 'lib/when_exe/calendartypes.rb', line 1592

def margin
  @margin
end

#numNumeric (readonly)

座標の分子

Returns:



1568
1569
1570
# File 'lib/when_exe/calendartypes.rb', line 1568

def num
  @num
end

Instance Method Details

#position(date, delta = 0) ⇒ Array<Integer>

日付に対応する座標

Parameters:

Returns:

  • (Array<Integer>)

    Array< Integer, 0 or 1 or 2 >

    Integer

    対応する座標

    0 or 1 or 2

    座標の進み(0 なら 没日, 2 なら滅)



1635
1636
1637
1638
1639
# File 'lib/when_exe/calendartypes.rb', line 1635

def position(date, delta=0)
  date = date.floor
  p0, p1 = [date, date.succ].map {|d| (@formula.time_to_cn(d)*30.0-@margin+delta).floor}
  [p1 % @den, p1-p0]
end

#term(date, parameter = nil, precision = date.precision) ⇒ When::TM::CalDate

イベントの日時

Parameters:

  • date (When::TM::TemporalPosition)

    イベントを探す基準とする日時

  • parameter (Array<Numeric>) (defaults to: nil)

    座標の分子と分母( num, den)

    num 座標の分子 (デフォルト @num)

    den 座標の分母 (デフォルト @den)

  • parameter (String) (defaults to: nil)

    座標の分子と分母(“#{ num }/#{ den }” の形式)

  • precision (Integer) (defaults to: date.precision)

    取得したい時間位置の分解能(デフォルト date の分解能)

Returns:



1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
# File 'lib/when_exe/calendartypes.rb', line 1608

def term(date, parameter=nil, precision=date.precision)
  precision = nil if precision == When::SYSTEM
  num, den  = parameter.kind_of?(String) ? parameter.split(/\//, 2) : parameter
  num = (num || @num).to_f
  den = (den || @den).to_f
  date      = date.floor(precision) if precision
  options   = date._attr
  quot, mod = (@formula.time_to_cn(date)*30.0).divmod(den)
  cycle     = quot * den + num
  cycle    += den if mod > num
  time      = When::TM::JulianDate._d_to_t(@formula.cn_to_time(cycle/30.0))
  time      = date.time_standard.from_dynamical_time(time) if @formula.is_dynamical
  date      = date.frame.jul_trans(When::TM::JulianDate.universal_time(time), options)
  precision ? date.floor(precision) : date
end

#term_delta(parameter = nil) ⇒ When::TM::IntervalLength

イベントの標準的な間隔を返す

Parameters:

  • parameter (String) (defaults to: nil)

    座標の分子と分母(“#{ num }/#{ den }” の形式)

Returns:



1647
1648
1649
1650
1651
# File 'lib/when_exe/calendartypes.rb', line 1647

def term_delta(parameter=nil)
  return @delta unless parameter
  num, den = parameter.split(/\//, 2)
  When::TM::IntervalLength.new([(den || @den).to_f-1,1].max, 'day')
end