Class: Tay::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/tay/utils.rb

Overview

Simple helpers used across various classes

Class Method Summary collapse

Class Method Details

.filesystem_name(name) ⇒ Object

Convert an extension name to a filesystem friendly name



7
8
9
# File 'lib/tay/utils.rb', line 7

def self.filesystem_name(name)
  name.gsub(/[^a-zA-Z0-9\-_ ]/, '').gsub(/ /, '_').downcase
end

.relative_path_to(path) ⇒ Object

Convert a path to be relative to pwd



13
14
15
16
17
18
# File 'lib/tay/utils.rb', line 13

def self.relative_path_to(path)
  if path.is_a?(String)
    path = Pathname.new(path)
  end
  path.relative_path_from(Pathname.new(Dir.pwd))
end