Class: Specdown::Hook
- Inherits:
-
Object
- Object
- Specdown::Hook
- Defined in:
- lib/specdown/hook.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(*filters, &callback) ⇒ Hook
constructor
A new instance of Hook.
- #matches?(filename) ⇒ Boolean
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
#call ⇒ Object
16 17 18 |
# File 'lib/specdown/hook.rb', line 16 def call @callback.call end |
#matches?(filename) ⇒ 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 |