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.
894 895 896 897 898 899 900 901 902 903 904 905 |
# File 'lib/liquid/standardfilters.rb', line 894 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
923 924 925 |
# File 'lib/liquid/standardfilters.rb', line 923 def compact to_a.compact end |
#concat(args) ⇒ Object
911 912 913 |
# File 'lib/liquid/standardfilters.rb', line 911 def concat(args) to_a.concat(args) end |
#each ⇒ Object
932 933 934 935 936 937 938 |
# File 'lib/liquid/standardfilters.rb', line 932 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
927 928 929 930 |
# File 'lib/liquid/standardfilters.rb', line 927 def empty? @input.each { return false } true end |
#join(glue) ⇒ Object
907 908 909 |
# File 'lib/liquid/standardfilters.rb', line 907 def join(glue) to_a.join(glue.to_s) end |
#reverse ⇒ Object
915 916 917 |
# File 'lib/liquid/standardfilters.rb', line 915 def reverse reverse_each.to_a end |
#uniq(&block) ⇒ Object
919 920 921 |
# File 'lib/liquid/standardfilters.rb', line 919 def uniq(&block) to_a.uniq(&block) end |