Class: Curlybars::PathFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/curlybars/path_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(ast) ⇒ PathFinder

Returns a new instance of PathFinder.



3
4
5
6
# File 'lib/curlybars/path_finder.rb', line 3

def initialize(ast)
  @ast = ast
  @matches = []
end

Instance Method Details

#find(target_path, role: nil) ⇒ Object

Find paths matching target_path. role: filters by syntactic role — :output, :helper, :argument, :option, :condition, :collection, :scope, :partial, or an Array of these.



11
12
13
14
15
16
17
# File 'lib/curlybars/path_finder.rb', line 11

def find(target_path, role: nil)
  @matches = []
  @target_segments = normalize_path(target_path)
  @role_filter = role
  traverse(@ast.template, [])
  @matches
end