Class: Amrita2::Filters::FilterArray

Inherits:
Array show all
Defined in:
lib/amrita2/template.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ FilterArray

Returns a new instance of FilterArray.



1962
1963
1964
# File 'lib/amrita2/template.rb', line 1962

def initialize(*args)
  args.each { |a| self << a }
end

Instance Method Details

#|(other) ⇒ Object



1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
# File 'lib/amrita2/template.rb', line 1966

def |(other)
  case other
  when Class
    a = self + [other.new]
    FilterArray.new(*a)
  when Filters::Base
    a = self + [other]
    FilterArray.new(*a)
  when Symbol
    self + FilterArray.new(FunctionFilter.new(other))
  when Array
    case other.first
    when Symbol
      self + FilterArray.new(FunctionFilter.new(*other))
    else
      self + other
    end
  else
    raise "not filter #{other.inspect}"
  end
end