module Embulk::Guess::TimeFormatGuess
Constants
- PATTERNS
Public Class Methods
guess(texts)
click to toggle source
# File lib/embulk/guess/time_format_guess.rb, line 391 def self.guess(texts) texts = Array(texts).map {|text| text.to_s } texts.reject! {|text| text == "" } matches = texts.map do |text| PATTERNS.map {|pattern| pattern.match(text) }.compact end.flatten if matches.empty? return nil elsif matches.size == 1 return matches[0].format else match_groups = matches.group_by {|match| match.mergeable_group }.values best_match_group = match_groups.sort_by {|group| group.size }.last best_match = best_match_group.shift best_match_group.each {|m| best_match.merge!(m) } return best_match.format end end