Class: Cease::Eviction::Chunk

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cease/eviction/chunk.rb

Instance Method Summary collapse

Constructor Details

#initialize(ast:, statement:) ⇒ Chunk

Returns a new instance of Chunk.



10
11
12
13
14
15
# File 'lib/cease/eviction/chunk.rb', line 10

def initialize(ast:, statement:)
  @ast = ast
  @statement = statement
  @closest_parent = nil
  @children = []
end

Instance Method Details

#extractArray<Parser::AST::Node>

Returns:

  • (Array<Parser::AST::Node>)


18
19
20
21
22
23
24
# File 'lib/cease/eviction/chunk.rb', line 18

def extract
  return ast if only_child?

  find_closest_parent(ast)
  find_children(closest_parent)
  children
end