Sha256: f04226aad2e3d2aa4928590ba73bd4436e5b7cb8ed943a9a474e4c0e1d1e6eac

Contents?: true

Size: 708 Bytes

Versions: 25

Compression:

Stored size: 708 Bytes

Contents

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

      module_function

      # @param yaml_file [String]
      # @return [Hash]
      def load_yaml_file(yaml_file)
        YAML.safe_load(File.read(yaml_file), permitted_classes: [Date], aliases: true)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rubicure-4.0.1 lib/rubicure/concerns/util.rb
rubicure-4.0.0 lib/rubicure/concerns/util.rb
rubicure-3.3.4 lib/rubicure/concerns/util.rb
rubicure-3.3.3 lib/rubicure/concerns/util.rb
rubicure-3.3.2 lib/rubicure/concerns/util.rb
rubicure-3.3.1 lib/rubicure/concerns/util.rb
rubicure-3.3.0 lib/rubicure/concerns/util.rb
rubicure-3.3.0.rc2 lib/rubicure/concerns/util.rb
rubicure-3.3.0.rc1 lib/rubicure/concerns/util.rb
rubicure-3.2.6 lib/rubicure/concerns/util.rb
rubicure-3.2.5 lib/rubicure/concerns/util.rb
rubicure-3.2.4 lib/rubicure/concerns/util.rb
rubicure-3.2.3 lib/rubicure/concerns/util.rb
rubicure-3.2.2 lib/rubicure/concerns/util.rb
rubicure-3.2.1 lib/rubicure/concerns/util.rb
rubicure-3.2.0 lib/rubicure/concerns/util.rb
rubicure-3.2.0.rc1 lib/rubicure/concerns/util.rb
rubicure-3.1.5 lib/rubicure/concerns/util.rb
rubicure-3.1.4 lib/rubicure/concerns/util.rb
rubicure-3.1.3 lib/rubicure/concerns/util.rb