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) ⇒ InputIterator

Returns a new instance of InputIterator.



410
411
412
413
414
415
416
417
418
419
420
# File 'lib/liquid/standardfilters.rb', line 410

def initialize(input)
  @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



438
439
440
# File 'lib/liquid/standardfilters.rb', line 438

def compact
  to_a.compact
end

#concat(args) ⇒ Object



426
427
428
# File 'lib/liquid/standardfilters.rb', line 426

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

#eachObject



447
448
449
450
451
# File 'lib/liquid/standardfilters.rb', line 447

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

#empty?Boolean

Returns:

  • (Boolean)


442
443
444
445
# File 'lib/liquid/standardfilters.rb', line 442

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

#join(glue) ⇒ Object



422
423
424
# File 'lib/liquid/standardfilters.rb', line 422

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

#reverseObject



430
431
432
# File 'lib/liquid/standardfilters.rb', line 430

def reverse
  reverse_each.to_a
end

#uniq(&block) ⇒ Object



434
435
436
# File 'lib/liquid/standardfilters.rb', line 434

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