Class: Filter

Inherits:
Object show all
Defined in:
lib/filters.rb

Direct Known Subclasses

FilterNonMatches

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp, nxt = nil, full_name = false) ⇒ Filter

Returns a new instance of Filter.



13
14
15
16
17
# File 'lib/filters.rb', line 13

def initialize(regexp, nxt = nil, full_name = false)
  @next = nxt
  @regexp = regexp
  @full_name = full_name
end

Instance Attribute Details

#full_nameObject

Returns the value of attribute full_name.



11
12
13
# File 'lib/filters.rb', line 11

def full_name
  @full_name
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/filters.rb', line 11

def name
  @name
end

#nextObject

Returns the value of attribute next.



11
12
13
# File 'lib/filters.rb', line 11

def next
  @next
end

#regexpObject

Returns the value of attribute regexp.



11
12
13
# File 'lib/filters.rb', line 11

def regexp
  @regexp
end

Class Method Details

.add(orig, nxt) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/filters.rb', line 3

def self.add(orig, nxt)
  if orig
    orig.add nxt
  else
    nxt
  end
end

Instance Method Details

#add(nxt) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/filters.rb', line 19

def add(nxt)
  if @next
    @next.add nxt
  else
    @next = nxt
  end
  self
end

#each {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Filter)

    the object that the method was called on



36
37
38
39
# File 'lib/filters.rb', line 36

def each(&b)
  yield self
  @next.each(&b) if @next
end

#filter(path, file) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/filters.rb', line 28

def filter(path, file)
  unless @regexp =~ text(path, file)
    next_filter(path, file)
  else
    false
  end
end