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.
910 911 912 913 914 915 916 917 918 919 920 921 |
# File 'lib/liquid/standardfilters.rb', line 910 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
939 940 941 |
# File 'lib/liquid/standardfilters.rb', line 939 def compact to_a.compact end |
#concat(args) ⇒ Object
927 928 929 |
# File 'lib/liquid/standardfilters.rb', line 927 def concat(args) to_a.concat(args) end |
#each ⇒ Object
948 949 950 951 952 953 954 |
# File 'lib/liquid/standardfilters.rb', line 948 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
943 944 945 946 |
# File 'lib/liquid/standardfilters.rb', line 943 def empty? @input.each { return false } true end |
#join(glue) ⇒ Object
923 924 925 |
# File 'lib/liquid/standardfilters.rb', line 923 def join(glue) to_a.join(glue.to_s) end |
#reverse ⇒ Object
931 932 933 |
# File 'lib/liquid/standardfilters.rb', line 931 def reverse reverse_each.to_a end |
#uniq(&block) ⇒ Object
935 936 937 |
# File 'lib/liquid/standardfilters.rb', line 935 def uniq(&block) to_a.uniq(&block) end |