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/calendartypes.rb,
lib/when_exe/region/indian.rb,
lib/when_exe/region/japanese_notes.rb,
lib/when_exe.rb
Overview
暦注 - Calendar Note
Direct Known Subclasses
CalendarNote::RomanNote, CalendarNote::ShireWeek, CalendarNote::WorldWeek, BalineseNote, Christian, HinduNote, JapaneseLuniSolarNote, JapaneseNote, JapaneseSolarNote, LuniSolarPositions
Defined Under Namespace
Modules: LabelAccess Classes: BalineseNote, Christian, DarianWeek, Enumerator, 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::干支']]
- YiNotes =
[['Yi::YearName'], ['_m:CalendarTerms::Month'], []]
- MayanNotes =
[["Mayan::Trecena", "Mayan::Tzolk'in", "Mayan::Lords_of_the_Night", "Mayan::Haab'"]]
Constants included from Parts::Resource
Parts::Resource::LabelProperty, Parts::Resource::Prefix, Parts::Resource::PrefixIndex, Parts::Resource::PrefixKeys, Parts::Resource::PrefixValues
Instance Attribute Summary collapse
-
#event ⇒ String
readonly
デフォルトイベント名.
Attributes inherited from TM::ReferenceSystem
#domain, #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 inherited from BasicTypes::Object
Methods included from Parts::Resource
#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, #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度のイベントすなわち秋分を意味します。
デフォルトイベント名
1149 1150 1151 |
# File 'lib/when_exe/calendartypes.rb', line 1149 def event @event end |
Instance Method Details
#copy(event) ⇒ When::CalendarTypes::CalendarNote
デフォルトイベントの指定
1158 1159 1160 1161 1162 |
# File 'lib/when_exe/calendartypes.rb', line 1158 def copy(event) c = self.clone c.event = event c end |
#duration(event = @event) ⇒ When::TM::PeriodDuration
典型的なイベントの発生間隔
1170 1171 1172 1173 |
# File 'lib/when_exe/calendartypes.rb', line 1170 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の生成
1199 1200 1201 |
# File 'lib/when_exe/calendartypes.rb', line 1199 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
指定の日時が指定イベントに該当するか?
1184 1185 1186 |
# File 'lib/when_exe/calendartypes.rb', line 1184 def include?(date, event=@event) enum_for(date, :forward, event.downcase).next.include?(date) end |
#note?(date, options = {}) ⇒ Boolean
暦注の一致 or 不一致
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 |
# File 'lib/when_exe/calendartypes.rb', line 1285 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, ...
暦注のビットアドレスは、暦注サブクラスのNoteObjects定数の中の定義順序による。 When::CalendarTypes::CalendarNote クラスの場合 new の引数とした暦注要素リストの定義順序による。 ビットアドレスの値が 1 の暦注が計算対象となる。
戻り値の :value が When::TM::TemporalPosition の場合、その日時オブジェクトの events に暦注名の入った 暦注に該当する日付である。(例) Christian クラス で easter を計算した場合、当該年の復活祭の日付オブジェクトが返る。
暦注サブクラスの場合、暦注要素が増えたり、:note の暦注要素の型が変わったりすることがある。
暦注の計算
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 |
# File 'lib/when_exe/calendartypes.rb', line 1247 def notes(date, ={}) dates, indices, notes, conditions, = _parse(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 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 |