Class: When::CalendarTypes::CalendarNote
- Inherits:
-
TM::ReferenceSystem
- Object
- BasicTypes::Object
- TM::Object
- TM::ReferenceSystem
- When::CalendarTypes::CalendarNote
- Defined in:
- lib/when_exe/calendartypes.rb,
lib/when_exe/region/indian.rb,
lib/when_exe/region/japanese_notes.rb,
lib/when_exe/region/ephemeric_notes.rb,
lib/when_exe.rb
Overview
暦注 - Calendar Note
Direct Known Subclasses
CalendarNote::RomanNote, CalendarNote::ShireWeek, CalendarNote::WorldWeek, BalineseNote, Christian, EphemericNote, HinduNote, JapaneseLuniSolarNote, JapaneseNote, JapaneseSolarNote, LuniSolarPositions
Defined Under Namespace
Modules: LabelAccess Classes: BalineseNote, Christian, DarianWeek, Enumerator, EphemericNote, HinduNote, HinduNoteDetailed, JapaneseLuniSolarNote, JapaneseNote, JapaneseSolarNote, LunarPhases, LuniSolarPositions, NoteElement, RomanNote, ShireWeek, SolarTerms, WorldWeek
Constant Summary collapse
- DefaultNotes =
[['_m:CalendarTerms::Month'], []]
- JulianDayNotes =
[['CommonResidue::Week', 'CommonResidue::干支']]
- BahaiNotes =
[['Bahai::YearName'], ['_m:BahaiTerms::Month'], []]
- JavaneseNotes =
[['Javanese::Windu'], ['_m:CalendarTerms::Month'], ['Javanese::Pasaran', 'Javanese::Paringkelan', 'Javanese::Week', 'Javanese::Wuku']]
- ChineseNotes =
[['CommonResidue::干支'], ['_m:CalendarTerms::Month'], ['CommonResidue::干支']]
- TibetanNotes =
[['Tibetan::干支'], ['_m:CalendarTerms::Month'], []]
- YiNotes =
[['Yi::YearName'], ['_m:CalendarTerms::Month'], []]
- MayanNotes =
[{'0B'=>{'Base'=>'?Epoch=0D'}, '2B'=>{'Base'=>'?Epoch=2D'}}, ['Mayan#{Base:}::Trecena', 'Mayan#{Base:}::Tzolk\'in', 'Mayan#{Base:}::Lords_of_the_Night', 'Mayan#{Base:}::Haab\'']]
Constants included from Parts::Resource
Parts::Resource::LabelProperty
Instance Attribute Summary collapse
-
#event ⇒ String
readonly
デフォルトイベント名.
Attributes inherited from TM::ReferenceSystem
#domain_of_validity, #position
Attributes inherited from BasicTypes::Object
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Instance Method Summary collapse
-
#copy(event) ⇒ When::CalendarTypes::CalendarNote
デフォルトイベントの指定.
- #day ⇒ When::BasicTypes::M17n
-
#duration(event = @event) ⇒ When::TM::PeriodDuration
典型的なイベントの発生間隔.
-
#enum_for(first, direction = :forward, event = @event, count_limit = nil) ⇒ Enumerator
(also: #to_enum)
Enumeratorの生成.
-
#include?(date, event = @event) ⇒ Boolean
指定の日時が指定イベントに該当するか?.
- #month ⇒ When::BasicTypes::M17n
-
#note?(date, options = {}) ⇒ Boolean
暦注の一致 or 不一致.
-
#notes(date, options = {}) ⇒ Hash, ...
暦注の計算.
- #year ⇒ When::BasicTypes::M17n
Methods inherited from TM::ReferenceSystem
Methods included from Parts::Resource
#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, _setup_, #each, #hierarchy, #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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::Parts::Resource
Instance Attribute Details
#event ⇒ String
イベント名の後ろに数字が使われている場合、数字部分以降はイベントメソッドの引数になります。 SolarTermsクラスで ‘term180’ は、太陽黄経180度のイベントすなわち秋分を意味します。
デフォルトイベント名
1152 1153 1154 |
# File 'lib/when_exe/calendartypes.rb', line 1152 def event @event end |
Instance Method Details
#copy(event) ⇒ When::CalendarTypes::CalendarNote
デフォルトイベントの指定
1161 1162 1163 1164 1165 |
# File 'lib/when_exe/calendartypes.rb', line 1161 def copy(event) c = self.clone c.event = event c end |
#duration(event = @event) ⇒ When::TM::PeriodDuration
典型的なイベントの発生間隔
1173 1174 1175 1176 |
# File 'lib/when_exe/calendartypes.rb', line 1173 def duration(event=@event) void, event, parameter = event.split(/^([^\d]+)/) send((event+'_delta').downcase.to_sym, parameter) end |
#enum_for(first, direction = :forward, event = @event, count_limit = nil) ⇒ Enumerator Also known as: to_enum
Enumeratorの生成
1202 1203 1204 |
# File 'lib/when_exe/calendartypes.rb', line 1202 def enum_for(first, direction=:forward, event=@event, count_limit=nil) Enumerator.new(self, first, direction, event, count_limit) end |
#include?(date, event = @event) ⇒ Boolean
指定の日時が指定イベントに該当するか?
1187 1188 1189 |
# File 'lib/when_exe/calendartypes.rb', line 1187 def include?(date, event=@event) enum_for(date, :forward, event.downcase).next.include?(date) end |
#note?(date, options = {}) ⇒ Boolean
暦注の一致 or 不一致
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 |
# File 'lib/when_exe/calendartypes.rb', line 1292 def note?(date, ={}) = _find_note() if .kind_of?(String) value = .delete(:value) if .kind_of?(Hash) result = notes(date, ) result = [result] unless result.kind_of?(Array) result = result.flatten.compact return false unless result.size > 0 return true unless value result.each do |hash| return true if value == hash[:value] end return false end |
#notes(date, options = {}) ⇒ Hash, ...
CalendarNoteオブジェクト生成時に _normalize メソッド内で @prime 変数を設定しておけば、 本メソッドの :prime オプションで参照される。(BalineseNote#_normalize等参照)
暦注のビットアドレスは、暦注サブクラスのNoteObjects定数の中の定義順序による。 When::CalendarTypes::CalendarNote クラスの場合 new の引数とした暦注要素リストの定義順序による。 ビットアドレスの値が 1 の暦注が計算対象となる。
戻り値の :value が When::TM::TemporalPosition の場合、その日時オブジェクトの events に暦注名の入った 暦注に該当する日付である。(例) Christian クラス で easter を計算した場合、当該年の復活祭の日付オブジェクトが返る。
暦注サブクラスの場合、暦注要素が増えたり、:note の暦注要素の型が変わったりすることがある。
暦注の計算
1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 |
# File 'lib/when_exe/calendartypes.rb', line 1253 def notes(date, ={}) dates, indices, notes, conditions, = _parse_note(date, ) _result(indices.map {|i| next [] unless i <= date.precision _note_values(dates, notes[i-1], _all_keys[i-1], _elements[i-1]) do |dates, focused_notes, notes_hash| focused_notes.each do |note| unless notes_hash[note] void, event, *parameter = note.split(/^([^\d]+)/) method = event.downcase parameter << conditions unless conditions.empty? notes_hash[note] = if respond_to?(method) send(method, dates, *parameter) else _elements[i-1][note].send(When::Coordinates::PRECISION_NAME[i].downcase, dates) end end end notes_hash end }, ) end |