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.
955 956 957 958 959 960 961 962 963 964 965 966 |
# File 'lib/liquid/standardfilters.rb', line 955 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
984 985 986 |
# File 'lib/liquid/standardfilters.rb', line 984 def compact to_a.compact end |
#concat(args) ⇒ Object
972 973 974 |
# File 'lib/liquid/standardfilters.rb', line 972 def concat(args) to_a.concat(args) end |
#each ⇒ Object
993 994 995 996 997 998 999 |
# File 'lib/liquid/standardfilters.rb', line 993 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
988 989 990 991 |
# File 'lib/liquid/standardfilters.rb', line 988 def empty? @input.each { return false } true end |
#join(glue) ⇒ Object
968 969 970 |
# File 'lib/liquid/standardfilters.rb', line 968 def join(glue) to_a.join(glue.to_s) end |
#reverse ⇒ Object
976 977 978 |
# File 'lib/liquid/standardfilters.rb', line 976 def reverse reverse_each.to_a end |
#uniq(&block) ⇒ Object
980 981 982 |
# File 'lib/liquid/standardfilters.rb', line 980 def uniq(&block) to_a.uniq(&block) end |