module Jekyll::Sanelist::SanelistFilter
Module containg sanelist filters
Constants
- DELIMITER
- ITEM
Public Instance Methods
sanelist(input)
click to toggle source
Takes a regular list and outputs a sanelist @param [Array] input The input list which needs to be converted into a sanelist @return [Array] A list of sane objects of items separated by delimiters
# 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
Private Instance Methods
get_delimiter(index, input_size)
click to toggle source
# File lib/jekyll/sanelist.rb, line 45 def get_delimiter(index, input_size) unless (index >= 0) && (input_size >= 2) && (index < (input_size - 1)) raise ArgumentError, 'Inputs index or input_size are invalid' end { 'isFirst' => (index == 0), 'isLast' => (index == (input_size - 2)), 'type' => DELIMITER } end
get_item(data, index, input_size)
click to toggle source
# File lib/jekyll/sanelist.rb, line 32 def get_item(data, index, input_size) unless (index >= 0) && (input_size >= 1) && (index < input_size) raise ArgumentError, 'Inputs index or input_size are invalid' end { 'data' => data, 'isFirst' => (index == 0), 'isLast' => (index == (input_size - 1)), 'type' => ITEM } end