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.
545 546 547 548 549 550 551 552 553 554 555 556 |
# File 'lib/liquid/standardfilters.rb', line 545 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
574 575 576 |
# File 'lib/liquid/standardfilters.rb', line 574 def compact to_a.compact end |
#concat(args) ⇒ Object
562 563 564 |
# File 'lib/liquid/standardfilters.rb', line 562 def concat(args) to_a.concat(args) end |
#each ⇒ Object
583 584 585 586 587 588 589 |
# File 'lib/liquid/standardfilters.rb', line 583 def each @input.each do |e| e = e.respond_to?(:to_liquid) ? e.to_liquid : e e.context = @context if e.respond_to?(:context=) yield(e) end end |
#empty? ⇒ Boolean
578 579 580 581 |
# File 'lib/liquid/standardfilters.rb', line 578 def empty? @input.each { return false } true end |
#join(glue) ⇒ Object
558 559 560 |
# File 'lib/liquid/standardfilters.rb', line 558 def join(glue) to_a.join(glue.to_s) end |
#reverse ⇒ Object
566 567 568 |
# File 'lib/liquid/standardfilters.rb', line 566 def reverse reverse_each.to_a end |
#uniq(&block) ⇒ Object
570 571 572 |
# File 'lib/liquid/standardfilters.rb', line 570 def uniq(&block) to_a.uniq(&block) end |