Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. def match(pattern, source)
  2. ruby_version = RUBY_VERSION.to_f
  3. node_pattern = NodePattern.new(pattern)
  4. ast = RuboCop::ProcessedSource.new(source, ruby_version).ast
  5. node_pattern.match(ast)
  6. end
  7.  
  8. match('(send nil? :sum $...)', 'sum(1,2,3,n)')
  9. # => [s(:int, 1), s(:int, 2), s(:int, 3), s(:send, nil, :n)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement