Class: When::CalendarNote::Week

Inherits:
When::CalendarNote show all
Defined in:
lib/when_exe/calendarnote.rb,
lib/when_exe/inspect.rb

Overview

暦週

Direct Known Subclasses

DiscordianWeek, ShireWeek, WorldWeek

Defined Under Namespace

Classes: DayOfWeek, Enumerator

Constant Summary

Constants inherited from When::CalendarNote

Bahai, CalendarDepend, Chinese, 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

Attributes inherited from When::CalendarNote

#event

Attributes inherited from TM::ReferenceSystem

#domain_of_validity, #position

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Instance Method Summary collapse

Methods inherited from When::CalendarNote

#copy, #day, #duration, #enum_for, #include?, #month, #note?, #notes, #year

Methods inherited from TM::ReferenceSystem

#domain, #name

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

#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 のためのコラムの生成

Returns:



218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/when_exe/inspect.rb', line 218

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

オブジェクトの正規化



749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
# File 'lib/when_exe/calendarnote.rb', line 749

def _normalize(args=[], options={})
  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].label.to_s.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 の決定

Returns:



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/when_exe/inspect.rb', line 192

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

#standard_week(date) ⇒ When::Coordinates::Residue

七曜

Parameters:

Returns:



742
743
744
# File 'lib/when_exe/calendarnote.rb', line 742

def standard_week(date)
  When.Residue('Week')[date.to_i % 7]
end

#week_labels(date) ⇒ Array<When::CalendarNote::Week::DayOfWeek>

曜日の名前の一覧



732
733
734
# File 'lib/when_exe/calendarnote.rb', line 732

def week_labels(date)
  @days_of_week.child[0...week(date)[:position].last]
end