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.
507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/liquid/standardfilters.rb', line 507 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
536 537 538 |
# File 'lib/liquid/standardfilters.rb', line 536 def compact to_a.compact end |
#concat(args) ⇒ Object
524 525 526 |
# File 'lib/liquid/standardfilters.rb', line 524 def concat(args) to_a.concat(args) end |
#each ⇒ Object
545 546 547 548 549 550 |
# File 'lib/liquid/standardfilters.rb', line 545 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
540 541 542 543 |
# File 'lib/liquid/standardfilters.rb', line 540 def empty? @input.each { return false } true end |
#join(glue) ⇒ Object
520 521 522 |
# File 'lib/liquid/standardfilters.rb', line 520 def join(glue) to_a.join(glue.to_s) end |
#reverse ⇒ Object
528 529 530 |
# File 'lib/liquid/standardfilters.rb', line 528 def reverse reverse_each.to_a end |
#uniq(&block) ⇒ Object
532 533 534 |
# File 'lib/liquid/standardfilters.rb', line 532 def uniq(&block) to_a.uniq(&block) end |