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
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