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-1.1.1 lib/rubicure/concerns/util.rb
rubicure-1.1.0 lib/rubicure/concerns/util.rb
rubicure-1.0.7 lib/rubicure/concerns/util.rb
rubicure-1.0.6 lib/rubicure/concerns/util.rb
rubicure-1.0.5 lib/rubicure/concerns/util.rb
rubicure-1.0.4 lib/rubicure/concerns/util.rb
rubicure-1.0.3 lib/rubicure/concerns/util.rb
rubicure-1.0.2 lib/rubicure/concerns/util.rb
rubicure-1.0.1 lib/rubicure/concerns/util.rb
rubicure-1.0.0 lib/rubicure/concerns/util.rb
rubicure-1.0.0.pre4 lib/rubicure/concerns/util.rb
rubicure-0.4.13 lib/rubicure/concerns/util.rb
rubicure-1.0.0.pre3 lib/rubicure/concerns/util.rb
rubicure-1.0.0.pre2 lib/rubicure/concerns/util.rb
rubicure-1.0.0.pre1 lib/rubicure/concerns/util.rb
rubicure-0.4.12 lib/rubicure/concerns/util.rb
rubicure-0.4.11 lib/rubicure/concerns/util.rb
rubicure-0.4.10 lib/rubicure/concerns/util.rb
rubicure-0.4.9 lib/rubicure/concerns/util.rb
rubicure-0.4.8 lib/rubicure/concerns/util.rb