Sha256: ecc3ac0716f2ce75db37ca28631e69f2a4d759a56b45809e17a533bec3fbbf63
Contents?: true
Size: 585 Bytes
Versions: 35
Compression:
Stored size: 585 Bytes
Contents
module Troy class ExtensionMatcher # # attr_reader :path # # attr_reader :performed # # attr_reader :matchers def initialize(path) @path = path @matchers = {} end def on(extension, &block) matchers[".#{extension}"] = block self end def default(&block) matchers["default"] = block self end def match matchers.each do |ext, handler| return handler.call if File.extname(path) == ext end matchers["default"].call if matchers["default"] end end end
Version data entries
35 entries across 35 versions & 1 rubygems