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



374
375
376
377
378
379
380
381
382
383
384
# File 'lib/liquid/standardfilters.rb', line 374

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



402
403
404
# File 'lib/liquid/standardfilters.rb', line 402

def compact
  to_a.compact
end

#concat(args) ⇒ Object



390
391
392
# File 'lib/liquid/standardfilters.rb', line 390

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

#eachObject



411
412
413
414
415
# File 'lib/liquid/standardfilters.rb', line 411

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

#empty?Boolean



406
407
408
409
# File 'lib/liquid/standardfilters.rb', line 406

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

#join(glue) ⇒ Object



386
387
388
# File 'lib/liquid/standardfilters.rb', line 386

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

#reverseObject



394
395
396
# File 'lib/liquid/standardfilters.rb', line 394

def reverse
  reverse_each.to_a
end

#uniq(&block) ⇒ Object



398
399
400
# File 'lib/liquid/standardfilters.rb', line 398

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