Class: Timely::TemporalPatterns::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/timely/temporal_patterns/finder.rb

Class Method Summary collapse

Class Method Details

.patterns(datetimes, options = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/timely/temporal_patterns/finder.rb', line 5

def patterns(datetimes, options = nil)
  return [] if datetimes.blank?
  options ||= {}

  datetimes = Array.wrap(datetimes).uniq.map(&:to_datetime).sort

  if options[:split].is_a?(ActiveSupport::Duration)
    find_patterns_split_by_duration(datetimes, options)
  elsif options[:split].is_a?(Numeric)
    find_patterns_split_by_size(datetimes, options)
  else
    find_patterns(datetimes, options)
  end
end