<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: symbol code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 05:14:17 GMT</pubDate>
    <description>DZone Snippets: symbol 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>
    <item>
      <title>High-performance Ruby: faster Symbol.to_s</title>
      <link>http://snippets.dzone.com/posts/show/2423</link>
      <description>Here's something that I found useful for shaving a few microseconds off. The performance gain ranges between 10% and 35%! YMMV.&lt;br /&gt;&lt;br /&gt;Note: updated with suggestion by trans.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Symbol&lt;br /&gt;  def to_s&lt;br /&gt;    @str_rep || (@str_rep = id2name.freeze)&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 15 Aug 2006 11:22:50 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2423</guid>
      <author>ciconia (Sharon Rosner)</author>
    </item>
    <item>
      <title>gen-sym</title>
      <link>http://snippets.dzone.com/posts/show/1150</link>
      <description>&lt;code&gt;&lt;br /&gt;REBOL [&lt;br /&gt;    Title: "Unique symbol generator"&lt;br /&gt;]&lt;br /&gt;&lt;br /&gt;gen-sym-ctx: context [&lt;br /&gt;    prefix: "&amp;"&lt;br /&gt;    counter: 0&lt;br /&gt;    clear: does [counter: 0]&lt;br /&gt;    set-prefix: func [value] [prefix: form value]&lt;br /&gt;    set 'gen-sym does [&lt;br /&gt;        counter: counter + 1&lt;br /&gt;        to word! join prefix counter&lt;br /&gt;    ]&lt;br /&gt;]&lt;br /&gt;&lt;br /&gt;repeat i 5 [print gen-sym]&lt;br /&gt;gen-sym-ctx/set-prefix 'G&lt;br /&gt;gen-sym-ctx/clear&lt;br /&gt;repeat i 5 [print gen-sym]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 13 Jan 2006 04:19:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1150</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
  </channel>
</rss>
