Class: Liquid::StandardFilters::InputIterator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/liquid/standardfilters.rb

Instance Method Summary collapse

Constructor Details

#initialize(input, context) ⇒ InputIterator

Returns a new instance of InputIterator.



957
958
959
960
961
962
963
964
965
966
967
968
# File 'lib/liquid/standardfilters.rb', line 957

def initialize(input, context)
  @context = context
  @input   = if input.is_a?(Array)
    input.flatten
  elsif input.is_a?(Hash)
    [input]
  elsif input.is_a?(Enumerable)
    input
  else
    Array(input)
  end
end

Instance Method Details

#compactObject



986
987
988
# File 'lib/liquid/standardfilters.rb', line 986

def compact
  to_a.compact
end

#concat(args) ⇒ Object



974
975
976
# File 'lib/liquid/standardfilters.rb', line 974

def concat(args)
  to_a.concat(args)
end

#eachObject



995
996
997
998
999
1000
1001
# File 'lib/liquid/standardfilters.rb', line 995

def each
  @input.each do |e|
    e = e.respond_to?(:to_liquid) ? e.to_liquid : e
    e.context = @context if e.respond_to?(:context=)
    yield(e)
  end
end

#empty?Boolean

Returns:

  • (Boolean)


990
991
992
993
# File 'lib/liquid/standardfilters.rb', line 990

def empty?
  @input.each { return false }
  true
end

#join(glue) ⇒ Object



970
971
972
# File 'lib/liquid/standardfilters.rb', line 970

def join(glue)
  to_a.join(glue.to_s)
end

#reverseObject



978
979
980
# File 'lib/liquid/standardfilters.rb', line 978

def reverse
  reverse_each.to_a
end

#uniq(&block) ⇒ Object



982
983
984
# File 'lib/liquid/standardfilters.rb', line 982

def uniq(&block)
  to_a.uniq(&block)
end