Sha256: 0633610f62fe66d7d282d6f74602e8f185ae717478d9654966c7995c7b320814

Contents?: true

Size: 424 Bytes

Versions: 1

Compression:

Stored size: 424 Bytes

Contents

# encoding: utf-8

class String
  # convert windows path to cygwin path
  #
  # ==== Examples
  #
  #   '/cygdrive/c/hoge/hoge.txt'.cygwinpath_to_winpath # => 'C:\hoge\hoge.txt'
  #
  def cygwinpath_to_winpath
    return self unless match(/\/cygdrive\//)
    drive = scan(/\/cygdrive\/(\w)\//).first.first.upcase
    dir_file = scan(/\/cygdrive\/\w\/(.*)/).first.first.gsub('/', '\\')
    "#{drive}:\\#{dir_file}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.102 lib/open_classes/string/cygwinpath_to_winpath.rb