Sha256: 5c464f14d7411c586aebcfb6d47e53ecea2d59afd8a51728f2852904cdc3fe16

Contents?: true

Size: 334 Bytes

Versions: 380

Compression:

Stored size: 334 Bytes

Contents

# frozen_string_literal: true

require 'active_support/core_ext/object/blank'
require 'pathname'

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

    to_s.blank? ? nil : ::Pathname.new(to_s)
  end
end

Version data entries

380 entries across 380 versions & 4 rubygems

Version Path
eac_ruby_utils-0.124.0 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.97.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.123.0 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.121.0 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.120.0 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.76.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.76.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.75.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.119.2 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.75.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.75.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.119.1 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.74.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.74.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.73.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.119.0 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.72.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.118.1 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_ruby_utils-0.118.0 lib/eac_ruby_utils/patches/object/to_pathname.rb
eac_tools-0.70.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb