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.
460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/liquid/standardfilters.rb', line 460 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
488 489 490 |
# File 'lib/liquid/standardfilters.rb', line 488 def compact to_a.compact end |
#concat(args) ⇒ Object
476 477 478 |
# File 'lib/liquid/standardfilters.rb', line 476 def concat(args) to_a.concat(args) end |
#each ⇒ Object
497 498 499 500 501 |
# File 'lib/liquid/standardfilters.rb', line 497 def each @input.each do |e| yield(e.respond_to?(:to_liquid) ? e.to_liquid : e) end end |
#empty? ⇒ Boolean
492 493 494 495 |
# File 'lib/liquid/standardfilters.rb', line 492 def empty? @input.each { return false } true end |
#join(glue) ⇒ Object
472 473 474 |
# File 'lib/liquid/standardfilters.rb', line 472 def join(glue) to_a.join(glue.to_s) end |
#reverse ⇒ Object
480 481 482 |
# File 'lib/liquid/standardfilters.rb', line 480 def reverse reverse_each.to_a end |
#uniq(&block) ⇒ Object
484 485 486 |
# File 'lib/liquid/standardfilters.rb', line 484 def uniq(&block) to_a.uniq(&block) end |