Class: Specdown::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/specdown/hook.rb

Instance Method Summary collapse

Constructor Details

#initialize(*filters, &callback) ⇒ Hook

Returns a new instance of Hook.



3
4
5
6
# File 'lib/specdown/hook.rb', line 3

def initialize(*filters, &callback)
  @filters = filters
  @callback = callback
end

Instance Method Details

#callObject



16
17
18
# File 'lib/specdown/hook.rb', line 16

def call
  @callback.call
end

#matches?(filename) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
# File 'lib/specdown/hook.rb', line 8

def matches?(filename)
  return true if @filters.empty?

  @filters.any? do |filter| 
    filter == filename || filter.match(filename)
  end
end