class Troy::ExtensionMatcher
Attributes
matchers[R]
path[R]
performed[R]
Public Class Methods
new(path)
click to toggle source
# File lib/troy/extension_matcher.rb, line 11 def initialize(path) @path = path @matchers = {} end
Public Instance Methods
default(&block)
click to toggle source
# File lib/troy/extension_matcher.rb, line 21 def default(&block) matchers["default"] = block self end
match()
click to toggle source
# File lib/troy/extension_matcher.rb, line 26 def match matchers.each do |ext, handler| return handler.call if File.extname(path) == ext end matchers["default"]&.call end
on(extension, &block)
click to toggle source
# File lib/troy/extension_matcher.rb, line 16 def on(extension, &block) matchers[".#{extension}"] = block self end