file extension methods
1 2 class File 3 # Feel free to add more here, as you need them. 4 Extensions = %r=^(txt|rb|markdown|textile|haml|sass|css|html|xhtml)$=i 5 6 module Extension 7 def method_missing(meth, *args) 8 if Extensions =~ meth.to_s 9 [self, '.', meth.to_s].join 10 else 11 super 12 end # if 13 end # method_missing 14 end # Extension 15 end # File 16 17 class Symbol 18 include File::Extension 19 end 20 class String 21 include File::Extension 22 end
1 2 'myfile'.html 3 # => "myfile.html" 4 5 :a_file.rb 6 # => "a_file.rb"