Sha256: b86faa7f2a51d6b32ac28771ba35dfea7f6d103457b24759f528d88fb49226e2

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

#encoding: UTF-8
module Str2Duck

  def self.activesupport
    require(File.join 'active_support','time')
  rescue LoadError
    return true
  end

  def self.parse str
    raise(ArgumentError,"invalid input, must be string like") unless str.class <= String
    @activesupport ||= activesupport
    [ :datetime, :date, :time, :true, :false, :float, :integer, :json, :yaml ].each do |method_name|
      if ::Str2Duck::Config.public_send(method_name)
        var = Str2Duck::Format.public_send method_name, str
        return var unless var.nil?
      end
    end

    return str

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
str2duck-1.7.1 lib/str2duck/parser.rb
str2duck-1.7.0 lib/str2duck/parser.rb