Class: JsDependency::ReplacePathAlias

Inherits:
Object
  • Object
show all
Defined in:
lib/js_dependency/replace_path_alias.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, alias_paths = nil) ⇒ ReplacePathAlias

Returns a new instance of ReplacePathAlias.

Parameters:

  • str (String)
  • alias_paths (Hash, nil) (defaults to: nil)


7
8
9
10
# File 'lib/js_dependency/replace_path_alias.rb', line 7

def initialize(str, alias_paths = nil)
  @str = str
  @alias_paths = alias_paths
end

Class Method Details

.call(str, alias_paths = nil) ⇒ String

Parameters:

  • str (String)
  • alias_paths (Hash, nil) (defaults to: nil)

Returns:

  • (String)


15
16
17
18
19
# File 'lib/js_dependency/replace_path_alias.rb', line 15

def self.call(str, alias_paths = nil)
  return str if alias_paths.nil? || alias_paths.empty?

  new(str, alias_paths).call
end

Instance Method Details

#callString

Returns:

  • (String)


22
23
24
25
26
# File 'lib/js_dependency/replace_path_alias.rb', line 22

def call
  return @str if safe_list.include?(@str)

  replace_alias_paths(@str, @alias_paths)
end