<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 09 Jun 2026 21:23:16 +0000</lastBuildDate>
    <item>
      <title>(Ruby) Ruby: Open a file, write to it, and close it in one line - stayce</title>
      <link>https://snipplr.com/view/34376/ruby-open-a-file-write-to-it-and-close-it-in-one-line</link>
      <description>&lt;p&gt;r - Open a file for reading. The file must exist.&#13;
w - Create an empty file for writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.&#13;
a - Append to a file. Writing operations append data at the end of the file. The file is created if it does not exist.&#13;
r+ - Open a file for update both reading and writing. The file must exist.&#13;
w+ - Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.&#13;
a+ - Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.&lt;/p&gt;</description>
      <pubDate>Thu, 13 May 2010 01:44:05 UTC</pubDate>
      <guid>https://snipplr.com/view/34376/ruby-open-a-file-write-to-it-and-close-it-in-one-line</guid>
    </item>
    <item>
      <title>(Ruby) validate with errors - stayce</title>
      <link>https://snipplr.com/view/33672/validate-with-errors</link>
      <description>&lt;p&gt;validate :price_must_be_at_least_a_cent&#13;
protected def price_must_be_at_least_a_cent&#13;
errors.add(:price, 'should be at least 0.01') if price.nil? || price &lt; 0.01&#13;
end&lt;/p&gt;</description>
      <pubDate>Fri, 30 Apr 2010 13:43:58 UTC</pubDate>
      <guid>https://snipplr.com/view/33672/validate-with-errors</guid>
    </item>
  </channel>
</rss>
