<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Technodolt's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 22 Jul 2008 23:22:19 GMT</pubDate>
    <description>DZone Snippets: Technodolt's Code Snippets</description>
    <item>
      <title>Ruby: make ranges always include the last value</title>
      <link>http://snippets.dzone.com/posts/show/3808</link>
      <description>So, in conjunction with other snipped about setting up intervals on Time, this can be added to Range to make sure it always includes the last value, even if the interval doesn't directly land you on the end value&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Range&lt;br /&gt;  def each(options = {}, &amp;block)&lt;br /&gt;    val = self.begin&lt;br /&gt;    while val &lt; self.end&lt;br /&gt;      yield val&lt;br /&gt;      val = val.succ&lt;br /&gt;    end&lt;br /&gt;    yield self.end if self.end == val || options[:always_include_last]&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 12 Apr 2007 17:36:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3808</guid>
      <author>technodolt (Luke Ivers)</author>
    </item>
    <item>
      <title>Ruby: set an interval for your Time (useful for ranges, especially)</title>
      <link>http://snippets.dzone.com/posts/show/3807</link>
      <description>&lt;code&gt;&lt;br /&gt;class Time&lt;br /&gt;  def set_interval(seconds)&lt;br /&gt;    @interval = seconds&lt;br /&gt;  end&lt;br /&gt;  def succ&lt;br /&gt;    @interval ||= 1&lt;br /&gt;    ret = self + @interval&lt;br /&gt;    ret.set_interval(@interval)&lt;br /&gt;    ret&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Thu, 12 Apr 2007 17:35:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3807</guid>
      <author>technodolt (Luke Ivers)</author>
    </item>
  </channel>
</rss>
