Module: General

Defined in:
lib/robust_excel_ole/general.rb

Defined Under Namespace

Classes: VBAMethodMissingError

Class Method Summary collapse

Class Method Details

.absolute_path(file) ⇒ Object

:nodoc: #



5
6
7
8
9
# File 'lib/robust_excel_ole/general.rb', line 5

def absolute_path(file)   # :nodoc: #
  file = File.expand_path(file)
  file = RobustExcelOle::Cygwin.cygpath('-w', file) if RUBY_PLATFORM =~ /cygwin/
  WIN32OLE.new('Scripting.FileSystemObject').GetAbsolutePathName(file)
end

.canonize(filename) ⇒ Object

:nodoc: #

Raises:

  • (TypeREOError)


11
12
13
14
# File 'lib/robust_excel_ole/general.rb', line 11

def canonize(filename)    # :nodoc: #
  raise TypeREOError, "No string given to canonize, but #{filename.inspect}" unless filename.is_a?(String)  
  normalize(filename).downcase
end

.normalize(path) ⇒ Object

:nodoc: #



16
17
18
19
20
21
22
# File 'lib/robust_excel_ole/general.rb', line 16

def normalize(path)       # :nodoc: #
  path = path.gsub('/./', '/') + '/'
  path = path.gsub(/[\/\\]+/, "/")
  nil while path.gsub!(/(\/|^)(?!\.\.?)([^\/]+)\/\.\.\//, '\1') 
  path = path.chomp("/")
  path
end