Class: When::CalendarNote::LuniSolarPositions
- Inherits:
-
When::CalendarNote
- Object
- BasicTypes::Object
- TM::Object
- TM::ReferenceSystem
- When::CalendarNote
- When::CalendarNote::LuniSolarPositions
- Defined in:
- lib/when_exe/ephemeris/notes.rb
Overview
太陽と月の位置によるイベント
Direct Known Subclasses
Constant Summary
Constants inherited from When::CalendarNote
Bahai, CalendarDepend, Chinese, CommonWithRokuyo, CommonWithSovietFiveDay, CommonWithSovietSixDay, Default, Javanese, JulianDay, Mayan, Tibetan, Yis
Constants included from Parts::Resource
Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty
Instance Attribute Summary collapse
-
#delta ⇒ Numeric
readonly
enumerator の周期.
-
#den ⇒ Numeric
readonly
座標の分母.
-
#formula ⇒ When::Ephemeris::Formula
readonly
計算アルゴリズム.
-
#margin ⇒ Numeric
readonly
没滅計算用の補正.
-
#num ⇒ Numeric
readonly
座標の分子.
Attributes inherited from When::CalendarNote
Attributes inherited from TM::ReferenceSystem
Attributes inherited from BasicTypes::Object
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Instance Method Summary collapse
-
#event_delta(parameter = nil) ⇒ When::TM::IntervalLength
イベントの標準的な間隔を返す.
-
#event_eval(date, parameter = @event, precision = nil) ⇒ When::TM::CalDate
イベントの日時.
-
#event_time(date, event_name, event) ⇒ Object
イベント日付(時刻付).
-
#position(date, delta = 0) ⇒ Array<Integer>
日付に対応する座標.
Methods inherited from When::CalendarNote
#copy, #day, #duration, #enum_for, #include?, #month, #note?, #notes, #year
Methods inherited from TM::ReferenceSystem
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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::Parts::Resource
Instance Attribute Details
#delta ⇒ Numeric (readonly)
enumerator の周期
39 40 41 |
# File 'lib/when_exe/ephemeris/notes.rb', line 39 def delta @delta end |
#den ⇒ Numeric (readonly)
座標の分母
27 28 29 |
# File 'lib/when_exe/ephemeris/notes.rb', line 27 def den @den end |
#formula ⇒ When::Ephemeris::Formula (readonly)
計算アルゴリズム
33 34 35 |
# File 'lib/when_exe/ephemeris/notes.rb', line 33 def formula @formula end |
#margin ⇒ Numeric (readonly)
没滅計算用の補正
45 46 47 |
# File 'lib/when_exe/ephemeris/notes.rb', line 45 def margin @margin end |
#num ⇒ Numeric (readonly)
座標の分子
21 22 23 |
# File 'lib/when_exe/ephemeris/notes.rb', line 21 def num @num end |
Instance Method Details
#event_delta(parameter = nil) ⇒ When::TM::IntervalLength
イベントの標準的な間隔を返す
116 117 118 119 120 |
# File 'lib/when_exe/ephemeris/notes.rb', line 116 def event_delta(parameter=nil) return @delta unless parameter num, den = parameter.kind_of?(String) ? parameter.split(/\//, 2) : parameter When::TM::IntervalLength.new([(den || @den).to_f,1].max*0.9, 'day') end |
#event_eval(date, parameter = @event, precision = nil) ⇒ When::TM::CalDate
イベントの日時
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/when_exe/ephemeris/notes.rb', line 61 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 = date._attr is_date_and_time = .key?(:clock) || precision > When::DAY [:precision] = precision [: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 += [:clock].universal_time(sdn.round) if [:clock].kind_of?(When::CalendarTypes::LocalTime) end event = date.frame.jul_trans(When::TM::JulianDate.universal_time(time), ) is_date_and_time ? event : event.to_cal_date end |
#event_time(date, event_name, event) ⇒ Object
イベント日付(時刻付)
126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/when_exe/ephemeris/notes.rb', line 126 def event_time(date, event_name, event) etime = term(date - When.Duration('P3D'), event, When::SYSTEM) if formula.respond_to?(:year_length) && formula.denominator && formula.denominator < 100000 fraction = etime.clk_time.local_time fraction += When::TM::Duration::DAY * (etime.to_i - date.to_i) fraction = (fraction / When::TM::Duration::DAY * formula.denominator * 1000 + 0.5).floor / 1000.0 fraction = fraction.to_i if fraction == fraction.to_i event_name + "(#{fraction}/#{formula.denominator})" else etime.events = [event_name] etime end end |
#position(date, delta = 0) ⇒ Array<Integer>
日付に対応する座標
102 103 104 105 106 |
# File 'lib/when_exe/ephemeris/notes.rb', line 102 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 |