Class: TimeFrame::CoveredFrame

Inherits:
Object
  • Object
show all
Defined in:
lib/time_frame/time_frame_covered.rb

Overview

Getting the covering time frame from a bunch of time_frame’s.

Instance Method Summary collapse

Constructor Details

#initialize(time_frames) ⇒ CoveredFrame

Returns a new instance of CoveredFrame.



5
6
7
# File 'lib/time_frame/time_frame_covered.rb', line 5

def initialize(time_frames)
  @time_frames = time_frames.reject(&:empty?)
end

Instance Method Details

#frameObject



9
10
11
12
13
14
# File 'lib/time_frame/time_frame_covered.rb', line 9

def frame
  return EMPTY unless @time_frames.any?
  min = @time_frames.min_by(&:min).min
  max = @time_frames.max_by(&:max).max
  TimeFrame.new(min: min, max: max)
end