Class: When::CalendarNote::Week
- Inherits:
-
When::CalendarNote
- Object
- BasicTypes::Object
- TM::Object
- TM::ReferenceSystem
- When::CalendarNote
- When::CalendarNote::Week
- Defined in:
- lib/when_exe/calendarnote.rb,
lib/when_exe/inspect.rb
Overview
暦週
Direct Known Subclasses
DiscordianWeek, InternationalFixedWeek, PositivistWeek, RokuyoWeek, ShireWeek, SovietFiveDayWeek, SovietSixDayWeek, TranquilityWeek, WorldSeasonWeek, WorldWeek
Defined Under Namespace
Classes: DayOfWeek, Enumerator
Constant Summary
Constants inherited from When::CalendarNote
Bahai, CalendarDepend, Chinese, CommonWithRokuyo, CommonWithSovietFiveDay, CommonWithSovietSixDay, Default, HashProperty, Javanese, JulianDay, Mayan, Tibetan, Yis
Constants included from Parts::Resource
Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIDecode, Parts::Resource::IRIDecodeTable, Parts::Resource::IRIEncode, Parts::Resource::IRIEncodeTable, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty
Instance Attribute Summary
Attributes inherited from When::CalendarNote
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
-
#_column_for_week_included(base, range, opt, &block) ⇒ Array<Object>
week_included のためのコラムの生成.
-
#_normalize(args = [], options = {}) ⇒ Object
オブジェクトの正規化.
-
#_range_for_week_included(date, first, length, block_given = false) ⇒ Array<Range>
week_included のための range の決定.
-
#common_week(date) ⇒ When::Coordinates::Residue
七曜.
-
#week_labels(date) ⇒ Array<When::CalendarNote::Week::DayOfWeek>
曜日の名前の一覧.
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 Method Details
#_column_for_week_included(base, range, opt, &block) ⇒ Array<Object>
week_included のためのコラムの生成
273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/when_exe/inspect.rb', line 273 def _column_for_week_included(base, range, opt, &block) count = 0 limit = week(base)[:position][1] range.inject([]) {|s,r| s + r.map { |date| position = week(date, base)[:position][0] (position - count).times do yield(nil,nil) end count = position + 1 yield(date, !opt.key?(:Range) || opt[:Range].include?(date.to_i) ? DAY : nil) if position < limit }} end |
#_normalize(args = [], options = {}) ⇒ Object
オブジェクトの正規化
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
# File 'lib/when_exe/calendarnote.rb', line 800 def _normalize(args=[], ={}) super @days_of_week ||= When.CalendarNote("#{self.class.to_s.split('::').last}/Notes::day::Week") @days_of_week.child.length.times do |index| name = @days_of_week.child[index].translate('en').downcase.gsub(/[- ]/, '_') self.class.module_eval %Q{ def #{name}(date, parameter=nil) @days_of_week.child[#{index}].just_or_last(date) end } unless respond_to?(name) self.class.module_eval %Q{ def #{name}_delta(parameter=nil) @days_of_week.child[#{index}].delta end } unless respond_to?(name + '_delta') end end |
#_range_for_week_included(date, first, length, block_given = false) ⇒ Array<Range>
week_included のための range の決定
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/when_exe/inspect.rb', line 247 def _range_for_week_included(date, first, length, block_given=false) begun = ended = nil if first <= 0 it = enum_for(date.floor, :reverse) (1-first).times do begun = it.next end else it = enum_for(date.floor, :forward) first.times do begun = it.next end end it = enum_for(begun, :forward) (length+1).times do ended = it.next end [begun...ended] end |
#common_week(date) ⇒ When::Coordinates::Residue
七曜
793 794 795 |
# File 'lib/when_exe/calendarnote.rb', line 793 def common_week(date) When.Residue('Week')[date.to_i % 7] end |
#week_labels(date) ⇒ Array<When::CalendarNote::Week::DayOfWeek>
曜日の名前の一覧
783 784 785 |
# File 'lib/when_exe/calendarnote.rb', line 783 def week_labels(date) @days_of_week.child[0...week(date)[:position].last] end |