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, context) ⇒ InputIterator
constructor
A new instance of InputIterator.
- #join(glue) ⇒ Object
- #reverse ⇒ Object
- #uniq(&block) ⇒ Object
Constructor Details
#initialize(input, context) ⇒ InputIterator
Returns a new instance of InputIterator.
479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/liquid/standardfilters.rb', line 479 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
#compact ⇒ Object
508 509 510 |
# File 'lib/liquid/standardfilters.rb', line 508 def compact to_a.compact end |
#concat(args) ⇒ Object
496 497 498 |
# File 'lib/liquid/standardfilters.rb', line 496 def concat(args) to_a.concat(args) end |
#each ⇒ Object
517 518 519 520 521 522 |
# File 'lib/liquid/standardfilters.rb', line 517 def each @input.each do |e| e.context = @context if e.respond_to?(:context=) yield(e.respond_to?(:to_liquid) ? e.to_liquid : e) end end |
#empty? ⇒ Boolean
512 513 514 515 |
# File 'lib/liquid/standardfilters.rb', line 512 def empty? @input.each { return false } true end |
#join(glue) ⇒ Object
492 493 494 |
# File 'lib/liquid/standardfilters.rb', line 492 def join(glue) to_a.join(glue.to_s) end |
#reverse ⇒ Object
500 501 502 |
# File 'lib/liquid/standardfilters.rb', line 500 def reverse reverse_each.to_a end |
#uniq(&block) ⇒ Object
504 505 506 |
# File 'lib/liquid/standardfilters.rb', line 504 def uniq(&block) to_a.uniq(&block) end |