Sha256: da737fb566980bb5f96264071bc7be5db15ec12c9d6752f8235b98cd674d2317

Contents?: true

Size: 370 Bytes

Versions: 177

Compression:

Stored size: 370 Bytes

Contents

# frozen_string_literal: true

require 'active_support/core_ext/object/blank'
require 'addressable/uri'

class Object
  # Convert +self+ to String and then to Addressable::URI. Return nil if +self+ is +blank?+.
  #
  # @return [Addressable::URI]
  def to_uri
    return self if is_a?(::Addressable::URI)

    to_s.blank? ? nil : ::Addressable::URI.parse(to_s)
  end
end

Version data entries

177 entries across 177 versions & 3 rubygems

Version Path
eac_tools-0.61.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.60.3 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.60.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.60.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.60.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.59.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.58.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.57.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.56.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.56.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.7 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.6 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.5 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.4 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.3 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_ruby_utils-0.112.0 lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb
eac_ruby_utils-0.111.0 lib/eac_ruby_utils/patches/object/to_uri.rb
eac_tools-0.55.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_uri.rb