<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="2.0">
<head>
<title>09.opml</title>
<dateCreated>Sun, 09 Dec 2007 02:38:32 GMT</dateCreated>
<dateModified>Sun, 09 Dec 2007 02:38:32 GMT</dateModified>
<ownerName>Tom Morris</ownerName>
</head>
<body>
<outline text="Ruby snippet for Macintosh battery status" created="Sun, 09 Dec 2007 02:38:32 GMT"><outline text="If you are using Mac OS X on a laptop, the following Ruby code may be useful:&#13;" created="Sun, 09 Dec 2007 02:38:32 GMT"/><outline text="&lt;code class=&quot;ruby&quot;&gt;ioreg_data = IO.popen(&quot;ioreg -w0 -l | grep Capacity&quot;).readlines()&lt;br /&gt;current = ioreg_data[0].scan(/[0-9]+/)[0].to_f&lt;br /&gt;max = ioreg_data[3].scan(/[0-9]+/)[0].to_f&lt;br /&gt;percent = (current / max) * 100&lt;br /&gt;puts percent.to_i.to_s&lt;/code&gt;&#13;" created="Sun, 09 Dec 2007 02:38:32 GMT"/><outline text="It does one very simple task - loads from &lt;a href=&quot;http://www.macosxhints.com/article.php?story=20050213125925746&quot;&gt;ioreg&lt;/a&gt; the battery statistics for your Mac, and just pulls the relevant numbers out using regular expressions and spits it back to you.&#13;" created="Sun, 09 Dec 2007 02:38:32 GMT"/><outline text="Tags: &lt;a href=&quot;http://search.tommorris.org/ruby&quot; rel=&quot;tag&quot;&gt;ruby&lt;/a&gt; &lt;a href=&quot;http://search.tommorris.org/os+x&quot; rel=&quot;tag&quot;&gt;os x&lt;/a&gt; &lt;a href=&quot;http://search.tommorris.org/ioreg&quot; rel=&quot;tag&quot;&gt;ioreg&lt;/a&gt; &lt;a href=&quot;http://search.tommorris.org/regex&quot; rel=&quot;tag&quot;&gt;regex&lt;/a&gt;" created="Sun, 09 Dec 2007 02:38:32 GMT"/></outline></body>
</opml>
