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