<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: extension code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 07 Oct 2008 06:51:22 GMT</pubDate>
    <description>DZone Snippets: extension code</description>
    <item>
      <title>file extension methods</title>
      <link>http://snippets.dzone.com/posts/show/5509</link>
      <description>Allows you to use file extensions as methods&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class File&lt;br /&gt;  # Feel free to add more here, as you need them.&lt;br /&gt;  Extensions = %r=^(txt|rb|markdown|textile|haml|sass|css|html|xhtml)$=i&lt;br /&gt;  &lt;br /&gt;  module Extension&lt;br /&gt;    def method_missing(meth, *args)&lt;br /&gt;      if Extensions =~ meth.to_s&lt;br /&gt;        [self, '.', meth.to_s].join&lt;br /&gt;      else&lt;br /&gt;        super&lt;br /&gt;      end # if&lt;br /&gt;    end # method_missing&lt;br /&gt;  end # Extension&lt;br /&gt;end # File&lt;br /&gt;&lt;br /&gt;class Symbol&lt;br /&gt;  include File::Extension&lt;br /&gt;end&lt;br /&gt;class String&lt;br /&gt;  include File::Extension&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;'myfile'.html&lt;br /&gt;# =&gt; "myfile.html"&lt;br /&gt;&lt;br /&gt;:a_file.rb&lt;br /&gt;# =&gt; "a_file.rb"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 17 May 2008 02:08:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5509</guid>
      <author>elliottcable (elliott cable)</author>
    </item>
  </channel>
</rss>
