Class: Liquid::StandardFilters::InputIterator
- Inherits:
-
Object
- Object
- Liquid::StandardFilters::InputIterator
- Includes:
- Enumerable
- Defined in:
- lib/liquid/standardfilters.rb
Instance Method Summary collapse
- #compact ⇒ Object
- #concat(args) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(input) ⇒ InputIterator
constructor
A new instance of InputIterator.
- #join(glue) ⇒ Object
- #reverse ⇒ Object
- #uniq(&block) ⇒ Object
Constructor Details
#initialize(input) ⇒ InputIterator
Returns a new instance of 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
#compact ⇒ Object
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 |
#each ⇒ Object
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 |
#reverse ⇒ Object
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 |