Class: TimePoint::Union
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Union
Returns a new instance of Union.
377
378
379
380
381
|
# File 'lib/time_point.rb', line 377
def initialize(*args)
@set = args.select {|e| e.is_a?(TimePoint)}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Sends all other methods to the set array.
406
407
408
409
410
411
412
413
|
# File 'lib/time_point.rb', line 406
def method_missing(name, *args, &block)
if set.respond_to?(name)
args << block if block_given?
set.send(name, *args)
else
super
end
end
|
Instance Method Details
#eql?(other) ⇒ Boolean
395
396
397
398
399
400
401
402
|
# File 'lib/time_point.rb', line 395
def eql?(other)
if other.is_a?(TimePoint::Union)
set.length == other.length && set.length.times { |i| return false unless set[i].eql? other[i] }
else
raise "Comparison of TimePointSet with something different (#{other.class.name})."
end
end
|
#include?(other) ⇒ Boolean
383
384
385
|
# File 'lib/time_point.rb', line 383
def include?(other)
set.any? {|tp| tp.include?(other)}
end
|
#occurrances_on_day(other) ⇒ Object
391
392
393
|
# File 'lib/time_point.rb', line 391
def occurrances_on_day(other)
set.inject([]) {|a,tp| a.concat(tp.occurrances_on_day(other)); a}
end
|
#occurs_on_day?(other) ⇒ Boolean
387
388
389
|
# File 'lib/time_point.rb', line 387
def occurs_on_day?(other)
set.any? {|tp| tp.occurs_on_day?(other)}
end
|
373
374
375
|
# File 'lib/time_point.rb', line 373
def set
@set ||= []
end
|