Sha256: 5106885df8fb5c8e940633a4e4f22643565d3754393ab30c6b6cd06b71288670

Contents?: true

Size: 497 Bytes

Versions: 2

Compression:

Stored size: 497 Bytes

Contents

# frozen_string_literal: true

module Gooday
  module Modules
    module StringParser
      def parse_string(string)
        parsed = translations[:regexes].each_with_object([]) do |regex, arr|
          arr << string.match(regex) if string.match?(regex)
        end
        return nil if parsed.empty?

        parsed.map { |p| Gooday.new(DateTime.new(p["year"].to_i || Time.now.year, translations[:months].index(p["month"]) & +1 || p["month"].to_i, p["day"].to_i)) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooday-0.1.2 lib/gooday/modules/string_parser.rb
gooday-0.1.1 lib/gooday/modules/string_parser.rb