Class: Polites::ListIndenter

Inherits:
Object
  • Object
show all
Defined in:
lib/polites/list_indenter.rb

Overview

Modify the AST for a parsed sheet to group list items in a nested structure, rather than a flat structure using levels.

Defined Under Namespace

Classes: List

Instance Method Summary collapse

Instance Method Details

#call(items) ⇒ Array<Polites::Node>

Parameters:

Returns:



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

def call(items)
  items
    .chunk { |i| i.is_a?(Block::List) }.to_a
    .inject([]) do |acc, (k, contents)|
    acc + (k ? [List.new(indent(contents))] : contents)
  end
end