module TheSchemaIs::Cops::NodeRefinements
Public Instance Methods
arraify()
click to toggle source
# File lib/the_schema_is/cops/node_util.rb, line 58 def arraify type == :begin ? children : [self] end
ast_match(expr)
click to toggle source
# File lib/the_schema_is/cops/node_util.rb, line 54 def ast_match(expr) Patterns.match(expr, self).to_a.first end
ast_search(expr)
click to toggle source
# File lib/the_schema_is/cops/node_util.rb, line 50 def ast_search(expr) Patterns.search(expr, self).to_a end
find_parent(type)
click to toggle source
# File lib/the_schema_is/cops/node_util.rb, line 68 def find_parent(type) Enumerator.produce(parent, &:parent).slice_after { |n| n && n.type == type }.first.last end
next_sibling()
click to toggle source
# File lib/the_schema_is/cops/node_util.rb, line 62 def next_sibling return unless parent parent.children.index(self).then { |i| parent.children[i + 1] } end