Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/sashimi/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#to_absolute_pathObject Also known as: to_abs_path

Transform the current Array to an absolute path.

%w(path to app).to_absolute_path # => /Users/luca/path/to/app
%w(path to app).to_abs_path # => /Users/luca/path/to/app


18
19
20
# File 'lib/sashimi/core_ext/array.rb', line 18

def to_absolute_path
  to_path(true)
end

#to_path(absolute = false) ⇒ Object

Transform the current Array to a path.

It’s an alias for File#join.

%w(path to app).to_path # => path/to/app+
%w(path to app).to_path(true) # => /Users/luca/path/to/app


8
9
10
11
12
# File 'lib/sashimi/core_ext/array.rb', line 8

def to_path(absolute = false)
  path = File.join(self)
  path = File.expand_path(path) if absolute
  path
end