Module: Jekyll::Sanelist::SanelistFilter

Defined in:
lib/jekyll/sanelist.rb

Overview

Module containg sanelist filters

Constant Summary collapse

ITEM =
'item'
DELIMITER =
'delimiter'

Instance Method Summary collapse

Instance Method Details

#sanelist(input) ⇒ Array

Takes a regular list and outputs a sanelist

Parameters:

  • input (Array)

    The input list which needs to be converted into a sanelist

Returns:

  • (Array)

    A list of sane objects of items separated by delimiters

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jekyll/sanelist.rb', line 18

def sanelist(input)
  raise ArgumentError, 'Input to filter sanelist is not an Array' unless input.is_a?(Array)

  output = []

  input.each_with_index do |value, index|
    output << get_item(value, index, input.size)

    output << get_delimiter(index, input.size) if index != (input.size - 1)
  end

  output
end