Class: When::CalendarNote::LuniSolarPositions

Inherits:
When::CalendarNote show all
Defined in:
lib/when_exe/ephemeris/notes.rb

Overview

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

Direct Known Subclasses

LunarPhases, SolarTerms

Constant Summary

Constants inherited from When::CalendarNote

Bahai, CalendarDepend, Chinese, CommonWithRokuyo, CommonWithSovietFiveDay, CommonWithSovietSixDay, Default, Javanese, JulianDay, Mayan, Tibetan, Yis

Constants included from Namespace

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

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from When::CalendarNote

#event

Attributes inherited from TM::ReferenceSystem

#domain_of_validity

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#child, #keys, #locale, #namespace

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from When::CalendarNote

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

Methods inherited from TM::ReferenceSystem

#domain, #name

Methods included from Parts::Resource

#[], #^, _instance, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir

Methods included from Parts::Resource::Pool

#[], #[]=, #_setup_

Dynamic Method Handling

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

Class Attribute Details

.table_offBoolean

高精度テーブル使用の指定状態

Returns:

  • (Boolean)

    true - 使用しない, false,nil - 使用する



23
24
25
# File 'lib/when_exe/ephemeris/notes.rb', line 23

def table_off
  @table_off
end

Instance Attribute Details

#deltaNumeric (readonly)

enumerator の周期

Returns:



65
66
67
# File 'lib/when_exe/ephemeris/notes.rb', line 65

def delta
  @delta
end

#denNumeric (readonly)

座標の分母

Returns:



53
54
55
# File 'lib/when_exe/ephemeris/notes.rb', line 53

def den
  @den
end

#formulaWhen::Ephemeris::Formula (readonly)

計算アルゴリズム



59
60
61
# File 'lib/when_exe/ephemeris/notes.rb', line 59

def formula
  @formula
end

#marginNumeric (readonly)

没滅計算用の補正

Returns:



71
72
73
# File 'lib/when_exe/ephemeris/notes.rb', line 71

def margin
  @margin
end

#numNumeric (readonly)

座標の分子

Returns:



47
48
49
# File 'lib/when_exe/ephemeris/notes.rb', line 47

def num
  @num
end

Class Method Details

._setup_(table_off = nil) ⇒ void

This method returns an undefined value.

Parameters:

  • table_off (Boolean) (defaults to: nil)

    高精度テーブル使用の指定 true - 使用しない, false,nil - 使用する



30
31
32
# File 'lib/when_exe/ephemeris/notes.rb', line 30

def _setup_(table_off=nil)
  @table_off = table_off
end

._setup_infoHash

設定情報を取得する

Returns:

  • (Hash)

    設定情報



38
39
40
# File 'lib/when_exe/ephemeris/notes.rb', line 38

def _setup_info
  {:table_off => @table_off}
end

Instance Method Details

#event_eval(date, parameter = @event, precision = nil) ⇒ When::TM::CalDate

イベントの日時

Parameters:

  • date (When::TM::TemporalPosition)

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

  • parameter (Array<Numeric>) (defaults to: @event)

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

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

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

  • parameter (String) (defaults to: @event)

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

  • precision (Integer) (defaults to: nil)

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

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/when_exe/ephemeris/notes.rb', line 87

def event_eval(date, parameter=@event, precision=nil)
  date         = When.when?(date) unless date.kind_of?(When::TimeValue)
  precision  ||= date.precision
  num, den     = parameter.kind_of?(String) ? (parameter[/\d.*\z/]||'').split(/\//, 2) : parameter
  num = (num || @num).to_f
  den = (den || @den).to_f
  date      = date.floor(precision) if precision < date.precision
  options   = date._attr
  is_date_and_time = options.key?(:clock) || precision > When::DAY
  options[:precision] = precision
  options[:clock]   ||= date.frame.time_basis || When::TM::Clock.local_time
  sdn       = _the_date(date, num, den)
  time      = When::TM::JulianDate._d_to_t(sdn)
  if @formula.is_dynamical
    time    = date.time_standard.from_dynamical_time(time)
    time   += options[:clock].universal_time(sdn.round) if options[:clock].kind_of?(When::CalendarTypes::LocalTime)
  end
  event = date.frame.jul_trans(When::TM::JulianDate.universal_time(time), options)
  is_date_and_time ? event : event.to_cal_date
end

#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 なら滅)



128
129
130
131
132
# File 'lib/when_exe/ephemeris/notes.rb', line 128

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