Sha256: b81349497f9fae994d7f9dac59f08e187032e3abf7b19b004f85e6638d72eafc

Contents?: true

Size: 325 Bytes

Versions: 7

Compression:

Stored size: 325 Bytes

Contents

# frozen_string_literal: true

module SumFilter
  # Sums the items in the array
  #
  # input - the object array
  #
  # Returns the sum
  def sum(input)
    return input unless input.respond_to?(:sum)

    input = input.values if input.is_a?(Hash) # FIXME
    input.sum
  end
end
Liquid::Template.register_filter(SumFilter)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
liquidum-1.2.1 lib/liquidum/liquid/filters/sum_filter.rb
liquidum-1.2.0 lib/liquidum/liquid/filters/sum_filter.rb
liquidum-1.1.2 lib/liquidum/liquid/filters/sum_filter.rb
liquidum-1.1.1 lib/liquidum/liquid/filters/sum_filter.rb
liquidum-1.1.0 lib/liquidum/liquid/filters/sum_filter.rb
liquidum-1.0.22 lib/liquidum/liquid/filters/sum_filter.rb
liquidum-1.0.17 lib/liquidum/liquid/filters/sum_filter.rb