Liquid::Utils

Public Class Methods

non_blank_string?(collection) click to toggle source
# File lib/liquid/utils.rb, line 26
def self.non_blank_string?(collection)
  collection.is_a?(String) && collection != ''
end
slice_collection_using_each(collection, from, to) click to toggle source
# File lib/liquid/utils.rb, line 3
def self.slice_collection_using_each(collection, from, to)
  segments = []
  index = 0

  # Maintains Ruby 1.8.7 String#each behaviour on 1.9
  return [collection] if non_blank_string?(collection)

  collection.each do |item|

    if to && to <= index
      break
    end

    if from <= index
      segments << item
    end

    index += 1
  end

  segments
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.