Class: When::V::Event::Enumerator::Logic
- Inherits:
-
Object
- Object
- When::V::Event::Enumerator::Logic
- Defined in:
- lib/when_exe/icalendar.rb
Overview
多重繰り返しロジック
Defined Under Namespace
Classes: Enumerator, Hour, Minute, Month, Monthday, Residue, Second, Weekday, Weekno, Yearday
Instance Attribute Summary collapse
-
#by_part ⇒ Object
readonly
Returns the value of attribute by_part.
-
#cash ⇒ Object
Returns the value of attribute cash.
-
#freq_index ⇒ Object
Returns the value of attribute freq_index.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #_bound(seed, week_start) ⇒ Object
-
#_candidates(lower_bound, higher_bound) ⇒ Object
候補日時の生成.
-
#initialize(by_part, list) ⇒ Logic
constructor
A new instance of Logic.
Constructor Details
#initialize(by_part, list) ⇒ Logic
Returns a new instance of Logic.
1528 1529 1530 1531 1532 1533 1534 1535 1536 |
# File 'lib/when_exe/icalendar.rb', line 1528 def initialize(by_part, list) @by_part = by_part @list = case list when String ; When::Coordinates::Pair::_en_pair_array(list) when Array ; else ; [list] end end |
Instance Attribute Details
#by_part ⇒ Object (readonly)
Returns the value of attribute by_part.
1474 1475 1476 |
# File 'lib/when_exe/icalendar.rb', line 1474 def by_part @by_part end |
#cash ⇒ Object
Returns the value of attribute cash.
1476 1477 1478 |
# File 'lib/when_exe/icalendar.rb', line 1476 def cash @cash end |
#freq_index ⇒ Object
Returns the value of attribute freq_index.
1473 1474 1475 |
# File 'lib/when_exe/icalendar.rb', line 1473 def freq_index @freq_index end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
1475 1476 1477 |
# File 'lib/when_exe/icalendar.rb', line 1475 def list @list end |
Instance Method Details
#_bound(seed, week_start) ⇒ Object
1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 |
# File 'lib/when_exe/icalendar.rb', line 1480 def _bound(seed, week_start) if @freq_index == When::WEEK # 週の初め bound = seed & week_start if bound == seed lower_bound = bound.floor(When::DAY, nil) higher_bound = lower_bound + week_start.duration else higher_bound = bound.floor(When::DAY, nil) lower_bound = higher_bound - week_start.duration end else # 指定桁で切り捨て/切り上げ lower_bound = seed.floor(@freq_index, nil) higher_bound = seed.ceil(@freq_index, nil) end return [lower_bound, higher_bound] end |
#_candidates(lower_bound, higher_bound) ⇒ Object
候補日時の生成
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 |
# File 'lib/when_exe/icalendar.rb', line 1501 def _candidates(lower_bound, higher_bound) # TODO unitBaseの扱い return @list.map { |ord| if (ord >= 0) period = ord - 1 bound = lower_bound else period = ord bound = higher_bound end index = PostFreqIndex[@by_part] period = ord-bound[index] if (index>0) result = bound + When::TM::PeriodDuration.new(period, index) if period > 0 && result.universal_time < lower_bound.universal_time clock = result.clock case clock.tz_prop when When::V::TimezoneProperty ; clock = clock.tz_prop.tzoffsetto when When::Parts::Timezone ; clock = clock.tz_prop.standard end result = result._copy({:date=>result.cal_date, :validate=>:done, :events=>nil, :time=>result.clk_time._copy({:clock=>clock})}) end result } end |