Class: When::CalendarNote
- Inherits:
-
TM::ReferenceSystem
- Object
- BasicTypes::Object
- TM::Object
- TM::ReferenceSystem
- When::CalendarNote
- Defined in:
- lib/when_exe/calendarnote.rb,
lib/when_exe/region/bahai.rb,
lib/when_exe/region/mayan.rb,
lib/when_exe/region/indian.rb,
lib/when_exe/region/chinese.rb,
lib/when_exe/region/martian.rb,
lib/when_exe/region/tibetan.rb,
lib/when_exe/ephemeris/notes.rb,
lib/when_exe/region/javanese.rb,
lib/when_exe/region/japanese/notes.rb,
lib/when_exe.rb
Overview
Ephemeris を用いる暦注
Direct Known Subclasses
Balinese, Christian, Ephemeris, HinduNote, Japanese, JapaneseLuniSolarNote, JapaneseSolarNote, LuniSolarPositions, Roman, Week, Zoroastrian
Defined Under Namespace
Modules: LabelAccess, NotesContainer Classes: Balinese, Christian, DarianWeek, DiscordianWeek, Enumerator, Ephemeris, HinduNote, HinduNoteDetailed, Japanese, JapaneseLuniSolarNote, JapaneseSolarNote, LunarPhases, LuniSolarPositions, NoteElement, Roman, ShireWeek, SolarTerms, Week, WorldWeek, Zoroastrian
Constant Summary collapse
- CalendarDepend =
暦法によってイベントの動作を変えるか否か
false- Bahai =
[['Bahai::YearName'], ['_m:Bahai::Month'], ['Common::Week']]
- Mayan =
[{},['Mayan#{?Epoch=Epoch}::Trecena', 'Mayan#{?Epoch=Epoch}::Tzolk\'in', 'Mayan#{?Epoch=Epoch}::Lords_of_the_Night', 'Mayan#{?Epoch=Epoch}::Haab\'']]
- Yis =
[['Yi::YearName'], ['_m:Calendar::Month'], ['Common::Week']]
- Tibetan =
[['Tibetan::干支'], ['_m:Calendar::Month'], ['Common::Week']]
- Javanese =
[['Javanese::Windu'], ['_m:Calendar::Month'], ['Javanese::Pasaran', 'Javanese::Paringkelan', 'Javanese::Week', 'Javanese::Wuku']]
- Default =
[['_m:Calendar::Month'], ['Common::Week']]
- JulianDay =
[['Common::Week', 'Common::干支']]
- Chinese =
[['Common::干支'], ['_m:Calendar::Month'], ['Common::Week', 'Common::干支']]
Constants included from Parts::Resource
Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIHeader, 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::CalendarNote
デフォルトイベントの指定.
- #day ⇒ When::BasicTypes::M17n
-
#duration(event = @event) ⇒ When::TM::PeriodDuration
典型的なイベントの発生間隔.
-
#enum_for(*args) ⇒ Enumerator
(also: #to_enum)
Enumeratorの生成.
-
#include?(date, event = @event) ⇒ Boolean
指定の日時が指定イベントに該当するか?.
- #month ⇒ When::BasicTypes::M17n
-
#note?(date, options = {}) ⇒ Boolean
暦注の一致 or 不一致.
-
#notes(date, options = {}) ⇒ Array<Array<Hash>>
暦注の計算.
- #year ⇒ When::BasicTypes::M17n
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, #hierarchy, #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
#event ⇒ String
イベント名の後ろに数字が使われている場合、数字部分以降はイベントメソッドの引数になります。SolarTermsクラスで ‘term180’ は、太陽黄経180度のイベントすなわち秋分を意味します。
デフォルトイベント名
217 218 219 |
# File 'lib/when_exe/calendarnote.rb', line 217 def event @event end |
Instance Method Details
#copy(event) ⇒ When::CalendarNote
デフォルトイベントの指定
226 227 228 229 230 |
# File 'lib/when_exe/calendarnote.rb', line 226 def copy(event) c = self.clone c.event = event c end |
#day ⇒ When::BasicTypes::M17n
|
|
# File 'lib/when_exe/calendarnote.rb', line 385
|
#duration(event = @event) ⇒ When::TM::PeriodDuration
典型的なイベントの発生間隔
238 239 240 241 |
# File 'lib/when_exe/calendarnote.rb', line 238 def duration(event=@event) void, event, parameter = event.split(/^([^\d]+)/) send((event+'_delta').downcase.to_sym, parameter) end |
#enum_for(range, options = {}) ⇒ Enumerator #enum_for(first, direction = :forward, options = {}) ⇒ Enumerator Also known as: to_enum
Enumeratorの生成
277 278 279 280 281 282 283 284 |
# File 'lib/when_exe/calendarnote.rb', line 277 def enum_for(*args) params = args.dup = params[-1].kind_of?(Hash) ? params.pop.dup : {} [:event] ||= @event self.class::Enumerator.new(*(params[0].kind_of?(Range) ? [self, params[0], ] : [self, params[0], params[1] || :forward, ])) end |
#include?(date, event = @event) ⇒ Boolean
指定の日時が指定イベントに該当するか?
252 253 254 |
# File 'lib/when_exe/calendarnote.rb', line 252 def include?(date, event=@event) enum_for(date, :forward, event.downcase).next.include?(date) end |
#month ⇒ When::BasicTypes::M17n
|
|
# File 'lib/when_exe/calendarnote.rb', line 381
|
#note?(date, options = {}) ⇒ Boolean
暦注の一致 or 不一致
363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/when_exe/calendarnote.rb', line 363 def note?(date, ={}) = _find_note() if .kind_of?(String) || .kind_of?(Regexp) pattern = .delete(:value) if .kind_of?(Hash) result = notes(date, ) result.flatten! result.delete_if {|hash| hash.empty?} return false unless result.size > 0 return true unless pattern result.each do |hash| return true if NotesContainer.verify(pattern, hash[:value]) end return false end |
#notes(date, options = {}) ⇒ Array<Array<Hash>>
CalendarNoteオブジェクト生成時に _normalize メソッド内で @prime 変数を設定しておけば、本メソッドの :prime オプションで参照される。(Balinese#_normalize等参照)
暦注のビットアドレスは、暦注サブクラスのNotes定数の中の定義順序による。When::CalendarNote クラスの場合 new の引数とした暦注要素リストの定義順序による。ビットアドレスの値が 1 の暦注が計算対象となる。
戻り値の :value が When::TM::TemporalPosition の場合、その日時オブジェクトの events に暦注名の入った暦注に該当する日付である。(例) Christian クラス で easter を計算した場合、当該年の復活祭の日付オブジェクトが返る。
暦注サブクラスの場合、暦注要素が増えたり、:note の暦注要素の型が変わったりすることがある。
暦注の計算
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/when_exe/calendarnote.rb', line 332 def notes(date, ={}) dates, indices, notes, persistence, conditions, = _parse_note(date, ) retrieved = NotesContainer.retrieve(persistence, date.to_i) return retrieved unless retrieved == false NotesContainer.register(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| notes_hash[note] ||= _note_element(note, i, conditions, dates) end notes_hash end }, persistence, date.to_i) end |
#year ⇒ When::BasicTypes::M17n
|
|
# File 'lib/when_exe/calendarnote.rb', line 377
|