Class: PathManipulator

Inherits:
Object
  • Object
show all
Defined in:
lib/src/extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(node_value_extractor) ⇒ PathManipulator

Returns a new instance of PathManipulator.



143
144
145
# File 'lib/src/extractor.rb', line 143

def initialize(node_value_extractor)
  @node_value_extractor = node_value_extractor
end

Instance Method Details



147
148
149
150
151
152
153
# File 'lib/src/extractor.rb', line 147

def replace_link(original_path, link_path)
  return original_path if link_path.blank?

  link_value = node_value_extractor.tag_values(link_path, nil)

  original_path.gsub "<link>", link_value
end

#uniq_paths(paths, uniq_by_path) ⇒ Object



155
156
157
158
159
160
# File 'lib/src/extractor.rb', line 155

def uniq_paths(paths, uniq_by_path)
  paths
    .map { |path| { path: path, value: tag_value(path, uniq_by_path) } }
    .then { |paths_values| remove_duplicated_paths(paths_values) }
    .map { |path_value| path_value[:path] }
end