<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>chris moos&#039;s blog &#187; gem</title>
	<atom:link href="http://chrismoos.com/tag/gem/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrismoos.com</link>
	<description>coding my way through life</description>
	<lastBuildDate>Sun, 18 Sep 2011 19:48:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>MoosTrax Ruby&#160;Library</title>
		<link>http://chrismoos.com/2009/02/23/moostrax-ruby-library/</link>
		<comments>http://chrismoos.com/2009/02/23/moostrax-ruby-library/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 21:28:35 +0000</pubDate>
		<dc:creator>Chris Moos</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[moostrax]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://chrismoos.com/?p=246</guid>
		<description><![CDATA[You can now access MoosTrax with Ruby. Install the gem 12$ wget http://www.moostrax.com/static/MoosTrax-0.1.gem $ sudo gem install MoosTrax-0.1.gem Try out this demo script make sure to fill your API_KEY in. 12345678910111213141516171819202122232425262728293031323334require 'rubygems' require 'moostrax' require 'time' def get_local_date&#40;date_str&#41; &#160; &#160; Time.parse&#40;date_str + ' UTC'&#41;.getlocal.asctime end mt = MoosTrax.new&#40;'API_KEY'&#41; begin &#160; &#160; devices = mt.devices &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>You can now access MoosTrax with Ruby.</p>
<h3>Install the gem</h3>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.moostrax.com<span style="color: #000000; font-weight: bold;">/</span>static<span style="color: #000000; font-weight: bold;">/</span>MoosTrax-<span style="color: #000000;">0.1</span>.gem<br />
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> MoosTrax-<span style="color: #000000;">0.1</span>.gem</div></td></tr></tbody></table></div>
<h3>Try out this demo script</h3>
<p>make sure to fill your API_KEY in.</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'moostrax'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'time'</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">def</span> get_local_date<span style="color:#006600; font-weight:bold;">&#40;</span>date_str<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>date_str <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">' UTC'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">getlocal</span>.<span style="color:#9900CC;">asctime</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
mt = MoosTrax.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'API_KEY'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">begin</span><br />
&nbsp; &nbsp; devices = mt.<span style="color:#9900CC;">devices</span><br />
&nbsp; &nbsp; devices.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>device<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; info = mt.<span style="color:#9900CC;">device_info</span><span style="color:#006600; font-weight:bold;">&#40;</span>device<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Device ID: #{info['device_id']}<span style="color:#000099;">\n</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Device Name: #{info['device_name']}<span style="color:#000099;">\n</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Last Contact: #{get_local_date(info['last_contact'])}<span style="color:#000099;">\n</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Date Added: #{get_local_date(info['date_added'])}<span style="color:#000099;">\n</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; location = mt.<span style="color:#9900CC;">location</span><span style="color:#006600; font-weight:bold;">&#40;</span>device<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Most Recent Location: #{location['latitude']}, #{location['longitude']} #{get_local_date(location['date'])}<span style="color:#000099;">\r</span><span style="color:#000099;">\n</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; history = mt.<span style="color:#9900CC;">history</span><span style="color:#006600; font-weight:bold;">&#40;</span>device, <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">86400</span>, <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Number of location updates in past 24 hours: #{history.length}<span style="color:#000099;">\r</span><span style="color:#000099;">\n</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;First Location in History: #{history[0]['latitude']}, #{history[0]['longitude']}<span style="color:#000099;">\r</span><span style="color:#000099;">\n</span>&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> history.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&gt;</span>=<span style="color:#006666;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'------------------------------------------------------'</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <br />
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">MoosTrax::APIError</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e<br />
&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Unable to access MoosTrax: #{e.message}&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>For more information, check out the <a href="http://trac.moostrax.com/trac/wiki/Developer_lib_Ruby">Developer API Wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrismoos.com/2009/02/23/moostrax-ruby-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

