Sha256: 6f3a040b3ae1b3e695a5ecfa4a3ffc251c7767022a032ef9da171084c8fc14bc

Contents?: true

Size: 462 Bytes

Versions: 25

Compression:

Stored size: 462 Bytes

Contents

module Rubicure
  module Concerns
    # utility methods
    module Util
      # @param arg
      # @return [Date] arg is String or Date
      # @return [Time] arg is Time
      # @return [nil] arg is other
      def to_date(arg)
        case arg
        when Date, Time
          arg
        when String
          begin
            Date.parse(arg)
          rescue
            nil
          end
        else
          nil
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rubicure-0.4.7 lib/rubicure/concerns/util.rb
rubicure-0.4.6 lib/rubicure/concerns/util.rb
rubicure-0.4.5 lib/rubicure/concerns/util.rb
rubicure-0.4.4 lib/rubicure/concerns/util.rb
rubicure-0.4.3 lib/rubicure/concerns/util.rb