Class: Pipeliner::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/pipeliner/Filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(t) ⇒ Filter

t

type of Objects filter is to be applied to

Create a new Filter

Raises:

  • (ArgumentError)


7
8
9
10
# File 'lib/pipeliner/Filter.rb', line 7

def initialize(t)
    raise ArgumentError.new('Expecting Class or String') unless [Class, String].include?(t.class)
    @type = t
end

Instance Attribute Details

#typeObject (readonly)

type of Objects filter is to be applied to



4
5
6
# File 'lib/pipeliner/Filter.rb', line 4

def type
  @type
end

Instance Method Details

#filter(o) ⇒ Object

o

Object from Pipeline

Applies filter to Object

Raises:

  • (ArgumentError)


14
15
16
17
# File 'lib/pipeliner/Filter.rb', line 14

def filter(o)
    raise ArgumentError.new('Wrong type supplied to filter') unless Splib.type_of?(o, @type)
    do_filter(o)
end