Class: Date

Inherits:
Object
  • Object
show all
Includes:
When::TM::TemporalPosition::Conversion
Defined in:
lib/when_exe/core/duration.rb,
lib/when_exe/core/extension.rb

Instance Method Summary collapse

Methods included from When::TM::TemporalPosition::Conversion

#julian_date

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)

Note:

self で定義されていないメソッドは tm_pos で変換して処理する

その他のメソッド



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/when_exe/core/extension.rb', line 90

def method_missing(name, *args, &block)
  return __method_missing(name, *args, &block) if When::Parts::MethodCash::Escape.key?(name)
  self.class.module_eval %Q{
    def #{name}(*args, &block)
      result = tm_pos.send("#{name}", *args, &block)
      result.kind_of?(When::TimeValue) ? result.to_date_or_datetime : result
    end
  } unless When::Parts::MethodCash.escape(name)
  result = tm_pos.send(name, *args, &block)
  result.kind_of?(When::TimeValue) ? result.to_date_or_datetime : result
end

Instance Method Details

#+(other) ⇒ ::Date

加算

Parameters:

  • other (When::TM::Duration)

    加える時間間隔(他の型の場合は動作に変更なし)

Returns:



48
49
50
# File 'lib/when_exe/core/duration.rb', line 48

def +(other)
  other.kind_of?(When::TM::Duration) ? self + other.rational_duration : self._plus_(other)
end

#-(other) ⇒ ::Date

減算

Parameters:

  • other (When::TM::Duration)

    減じる時間間隔(他の型の場合は動作に変更なし)

Returns:



62
63
64
65
66
67
68
# File 'lib/when_exe/core/duration.rb', line 62

def -(other)
  case other
  when When::TM::Duration ; self - other.rational_duration
  when When::TimeValue    ; self._minus_(other.to_date_or_datetime)
  else                    ; self._minus_(other)
  end
end

#_minus_Object



54
# File 'lib/when_exe/core/duration.rb', line 54

alias :_minus_ :-

#_plus_Object



40
# File 'lib/when_exe/core/duration.rb', line 40

alias :_plus_  :+

#tm_pos(options = {}) ⇒ When::TM::CalDate, When::TM::DateAndTime Also known as: to_tm_pos

Note:

暦法の指定がない場合、start メソッドの値によって Julian / Gregorian / Civil 暦法を選択する

対応する When::TM::CalDate or DateAndTime を生成

Parameters:

Returns:



73
74
75
76
# File 'lib/when_exe/core/extension.rb', line 73

def tm_pos(options={})
  options[:frame] ||= When::CalendarTypes::Christian._default_start(self)
  super(options)
end