<?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>Girl with Computer &#187; Ruby</title>
	<atom:link href="http://www.girlwithcomputer.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.girlwithcomputer.com</link>
	<description>== exactly that.</description>
	<lastBuildDate>Sun, 18 Sep 2011 22:47:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ruby, Javascript, and HTML/CSS (and Sinatra)</title>
		<link>http://www.girlwithcomputer.com/ruby-javascript-and-htmlcss-and-sinatra/</link>
		<comments>http://www.girlwithcomputer.com/ruby-javascript-and-htmlcss-and-sinatra/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 05:53:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/?p=124</guid>
		<description><![CDATA[I&#8217;ve mentioned before that I&#8217;m a bit of a Sinatra (http://sinatrarb.com) fan. Recently, at the Interlock hackerspace, I&#8217;ve been learning javascript from a friend/mentor. We&#8217;ve talked about the best ways to teach programming, and decided a fun way to start would be with javascript games. I really enjoy javascript so far. We started off using [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve mentioned before that I&#8217;m a bit of a Sinatra <a href="http://sinatrarb.com">(http://sinatrarb.com)</a> fan. Recently, at the <a href="http://interlockroc.org">Interlock hackerspace</a>, I&#8217;ve been learning javascript from a friend/mentor. We&#8217;ve talked about the best ways to teach programming, and decided a fun way to start would be with javascript games. I really enjoy javascript so far. We started off using a text editor (gedit) and browser (firefox) to develop a simple tic tac toe game. This was a good way to start. As soon as I went home for the night, I (switched to vim, initialized a git repo), moved the app over to Sinatra, and deployed with <a href="http://heroku.com">Heroku</a>. My restructuring took about 5 minutes, deployment took 5 seconds. Here is what I did.</p>
<h4><span style="text-decoration: underline;"><strong>Restructuring the Application </strong></span></h4>
<p>Initially, I had a directory which included a .js, .html, and .css file. To restructure my app for Sinatra, I changed my ~/projects/tictactoe directory to look like this:</p>
<p>|&#8211; config.ru<br />
|&#8211; public<br />
|   |&#8211; css<br />
|   |   `&#8211; style.css<br />
|   `&#8211; js<br />
|       |&#8211; tictactoe.js<br />
|&#8211; tictactoe.rb<br />
`&#8211; views<br />
`&#8211; layout.erb</p>
<h4><span style="text-decoration: underline;">Breaking down Sinatra</span></h4>
<p><strong>config.ru</strong> &#8211; I mentioned earlier that I deployed with Heroku (more on that in another post, but basically Heroku is a very simple, git-driven way to deploy rack applications&#8211; and you can use it for free). The config.ru file tells Heroku that this is a rack application. The contents of the file? Simple. &#8220;Sinatra::Application&#8221; That&#8217;s all I need.<br />
<strong>public</strong> &#8211; Your javascript and your CSS live here. Have as many as you want, and you simply link to your javascript and your css is your .erb files in your views directory, just as you would in the index.html of a site. Nothing fancy there.<br />
<strong>views</strong> &#8211; choose the templating language of your choice, and use it here. I use erb because I&#8217;m most familiar with it, but haml is exceedingly popular as well. Anything in <strong>layout.erb </strong>will show up on *every* page. Since my tic-tac-toe application is only one page, I only need one layout. I&#8217;ll talk about what happens if you have more pages in the next section.**<br />
<strong>tictactoe.rb</strong> &#8211; this is where the magic happens. Right now, this is all this file contains:</p>
<pre>require 'rubygems'
require 'sinatra'

get '/' do
erb :layout
end</pre>
<p><strong>require</strong> tells my app the dependencies it needs and loads them for me. <strong>get &#8216;/tiktaktoh&#8217;</strong> gets that route for me. <strong>do</strong> initiates the block that I&#8217;m about to pass which contains <strong>erb :layout</strong>, meaning my layout.erb file will be my &#8216;view&#8217; for this route. And, <strong>end</strong> closes my block. I have routed my application to the index page of my url. <a href="http://tiktaktoh.heroku.com">Check it.</a></p>
<h4><span style="text-decoration: underline;"><strong>Why the heck did I do *THAT*? </strong></span></h4>
<p>First, I can easily expand this. I can make jsgames.heroku.com and have &#8216;/tiktaktoh&#8217; route to my tiktaktoh layout, which would reference my stylesheet and my javascript for tiktaktoh. I can also make &#8216;/bingo&#8217; do the same thing. I can easily create a separate bingo.js and bingo.erb file to create that project completely separate. This is perfect for learning and keeping my code organized. All of this is easily handled through Sinatra&#8217;s routing capabilities in one easy file &#8212; maybe I&#8217;d call it games.rb instead of tiktaktoh.rb, and it might look like this:</p>
<pre>require 'rubygems'
require 'sinatra'

get '/tiktaktoh' do
erb :tiktaktoh
end

get '/bingo' do
erb :bingo
end</pre>
<p>jsgames.heroku.com/tiktaktoh would go to my tic-tac-toe app, and so on.</p>
<p>**I mentioned earlier that I  will still have a layout.erb that will be my default layout, but I will only keep things I want on *all pages* there (like header tags) and then I will insert the  ruby (erb) code &lt;%=yield%&gt; in layout.erb wherever I want the layout specific to each game to show up (bingo.erb or tiktaktoh.erb). If my bingo.erb and tiktaktoh.erb layouts are drastically different, I might limit my layout.erb file to header tags. Then, I would simply insert &lt;%=yield%&gt; between my opening and closing html tags. My bingo.erb and tiktaktoh.erb would then include all of the formatting necessary to make my games look pretty.</p>
<p>And second, after I set this up, I deployed with heroku in a quick and easy step, but that&#8217;s for another blog post.</p>
<h4><span style="text-decoration: underline;"><strong>Conclusion</strong></span></h4>
<p>I now have a well-organized, expandable, git-supervised and deployable project directory. And although it might seem like overkill for starters, I love how easy it is to develop locally and then deploy with a single command for free, and we can start with ajax requests whenever we want, when we get there. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can follow my slow and steady progress at<a href="http://github.com/ashumz/tiktaktoh"> http://github.com/ashumz/tiktaktoh</a> My thoughts are to turn this experience into a nice tutorial on beginning javascript for (new) rubyists.</p>
<p><strong>Currently Computing: </strong><br />
Me: HELLO AWESOME! What&#8217;s your name?<br />
Awesome: <a href="http://github.com/maccman/bowline">Bowline, a ruby/js GUI framework</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/ruby-javascript-and-htmlcss-and-sinatra/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easy Sinatra Project</title>
		<link>http://www.girlwithcomputer.com/sinatra/</link>
		<comments>http://www.girlwithcomputer.com/sinatra/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 03:54:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/sinatra/</guid>
		<description><![CDATA[I lovelovelove Sinatra. (SinatraRB.com) I created a very simple app (the fortune cookie generator I mentioned in an earlier post) to play with styling/views, get and post requests, and the very bare bones workings of Sinatra. I absolutely love how pure and simple it is. The structuring is a bit confusing at first, but the [...]]]></description>
			<content:encoded><![CDATA[<p>I lovelovelove Sinatra. (SinatraRB.com) I created a very simple app (the fortune cookie generator I mentioned in an earlier post) to play with styling/views, get and post requests, and the very bare bones workings of Sinatra. I absolutely love how pure and simple it is. The structuring is a bit confusing at first, but the Sinatra Peepcode video helped me a lot on this: <a href="http://peepcode.com/products/sinatra">http://peepcode.com/products/sinatra</a></p>
<p> In the Peepcode video, they make a Sinatra app in one file, and then break it down from there into separate files. It&#8217;s good to see how everything CAN fit in one file. This is how I learned CSS, actually&#8211; by putting my styles in with the rest of my website. Once I realized you put the CSS in a separate file, I had a mini epiphany: sometimes it&#8217;s best to put things together before you take them apart. Then you can truly appreciate the fragmentation of a given application and truly understand the purpose of breaking things up for simplicity&#8217;s sake. Seeing this helped me understand a lot about Sinatra, and even shed some light for me on why Rails is the way it is, as well. </p>
<p>So, dundundun: I made this: <a href="http://fortunefinder.heroku.com">http://fortunefinder.heroku.com </a></p>
<p>Don&#8217;t judge my poor styling and wacky coloration. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  This really was just a silly little experiment to play with the basic features of Sinatra. Now that I understand the basics, I&#8217;m moving on to another project confidently. I&#8217;ll still probably tweak this one a little, too. Just for fun.</p>
<p>You can check out the code on github at <a href="http://github.com/ashumz/fortunefinder">http://github.com/ashumz/fortunefinder</a> Nothing special, but might help a Sinatra newbie get a feel for the basic set up of a simple app.</p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-11489803-1");
pageTracker._trackPageview();
} catch(err) {}</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/sinatra/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Redefining the &#8220;+&#8221; method in Ruby</title>
		<link>http://www.girlwithcomputer.com/redefining-plus-method-in-ruby/</link>
		<comments>http://www.girlwithcomputer.com/redefining-plus-method-in-ruby/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 21:15:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby is cute]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/redefining-plus-method-in-ruby/</guid>
		<description><![CDATA[This is still one of my favorite things to do on a rainy day:
class Fixnum
  def + (x)
    self - x
  end
end

1 + 1
=&#62; 0
Don&#8217;t forget to redefine the + sign for floats as well! 1.3 + 2.1 would still equal 3.4, unless you do the same thing for class [...]]]></description>
			<content:encoded><![CDATA[<p>This is still one of my favorite things to do on a rainy day:</p>
<pre><strong><strong>class Fixnum
  def + (x)
    self - x
  end
end
</strong></strong></pre>
<p><strong>1 + 1<br />
=&gt; 0</strong></p>
<p>Don&#8217;t forget to redefine the + sign for floats as well! 1.3 + 2.1 would still equal 3.4, unless you do the same thing for class Float. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/redefining-plus-method-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sinatra: The answer to my Ruby GUI problem</title>
		<link>http://www.girlwithcomputer.com/ruby-to-gui-or-not-to-gui/</link>
		<comments>http://www.girlwithcomputer.com/ruby-to-gui-or-not-to-gui/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ruby gui]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/ruby-to-gui-or-not-to-gui/</guid>
		<description><![CDATA[Ruby and GUI&#8217;s have been on the forefront of my brain lately because I&#8217;ve been playing around with fun ways to program with Ruby. I am honestly bored of command line programs, and for good reason: the command line isn&#8217;t pretty enough for me. Since I&#8217;ve had problems installing Shoes and Hackety Hack on my [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby and GUI&#8217;s have been on the forefront of my brain lately because I&#8217;ve been playing around with fun ways to program with Ruby. I am honestly bored of command line programs, and for good reason: the command line isn&#8217;t pretty enough for me. Since I&#8217;ve had problems installing Shoes and Hackety Hack on my version of Ubuntu, I asked one of my friends who uses Ruby frequently if there were other GUI options. There are options, but he referred to them as a bit of a mess to implement and pointed out that javascript and the web make for better uses of, what I would call, &#8220;fun Ruby.&#8221; Better yet, when you program for the web, everyone can use your program without worrying about what platform they are on. </p>
<p>So, I gave this a little thought. I started getting jealous and even a little frustrated at Python programmers and their connectedness with GUI&#8217;s and their pride in Python&#8217;s support for GUI&#8217;s. Apparently, Ruby has similar support, but it&#8217;s not nearly as widely embraced amongst Rubyists as it is in the Python community. (True? False? opinions?) Admittedly, I think I should have just learned visual basic and got my GUI fix 10 years ago. (I don&#8217;t particularly want to learn Python, and there are issues with it&#8217;s syntax that have turned me off pretty heavily.)</p>
<p>So, I have decided that the best course of action, given my new fixation on Sinatra, is to begin a jquery/javascript and Ruby project. Although I&#8217;ve been making websites for about 10 years, they have generally been informative, usually static, very low level applications of HTML, CSS, and bits and pieces of PHP. I have used javascript for fun little menus now and again, but honestly I&#8217;m a total copy/paster when it comes to js. I started recently on some javascript tutorials, but was then quickly reprimanded: SKIP TO JQUERY, says everyone. Unless you really wanna become a pro in javascript, it sounds like jquery is a nice shortcut to the overwhelming syntax (especially coming from Ruby!) and implementations of javascript. I can&#8217;t quite figure out a consistency of why and how something does what in javascript. But, if I can figure out what I want the code to do, I&#8217;m pretty sure I can figure out how to use jquery to get the job done. We&#8217;ll see.</p>
<p>I am going to begin working on a blog that is purely in javascript, using jquery, and also uses Sinatra. I&#8217;m going to use sqlite for the DB. Did I mention I have very little experience with DB&#8217;s, too? <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Okay, this project, honestly, seems a little over my head to me right now. But once complete, I think I will have experience with all of these pieces I need to make a pretty, fun, and useful application. Something every programmer craves&#8211; right?! <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>Updates to follow. Thanks to <a href="http://juliocapote.com">Julio</a> for helping me come up with the idea on how to practice messing with all of the components I&#8217;m craving: Ruby, Sinatra, Javascript/Jquery, Sqlite, ERB, CSS&#8230; wee! This brings up another point about how multilingual and implementation exposure at the early stages of learning a programming language can be so incredibly integral to understanding how to best utilize a programming language like Ruby&#8230; but that&#8217;s for another post! Cheers! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/ruby-to-gui-or-not-to-gui/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails or Sinatra?</title>
		<link>http://www.girlwithcomputer.com/ruby-on-rails-or-sinatra/</link>
		<comments>http://www.girlwithcomputer.com/ruby-on-rails-or-sinatra/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 03:45:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/?p=42</guid>
		<description><![CDATA[My updates have been a little scarce, but I&#8217;ve been programming&#8211; I promise.  
I recently have been working on a site, discountcampusbooks.com (psst, buy your books there!) with my husband, alan.dipert.org. The book search is written in Ruby and uses the incredibly cute Ruby framework, Sinatra. I absolutely LOVE Sinatra, and I think for [...]]]></description>
			<content:encoded><![CDATA[<p>My updates have been a little scarce, but I&#8217;ve been programming&#8211; I promise. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I recently have been working on a site, <a href="http://discountcampusbooks.com">discountcampusbooks.com</a> (psst, buy your books there!) with my husband, <a href="http://alan.dipert.org">alan.dipert.org</a>. The book search is written in Ruby and uses the incredibly cute Ruby framework, Sinatra. I absolutely LOVE Sinatra, and I think for me it is a viable alternative to Rails. I&#8217;ve had pretty mixed feelings on ROR lately. I know I am a bit too opinionated for my skill level, but I really have something to say about the differences and advantages of both Rails and Sinatra.</p>
<p>I should say this first, because I feel like it:</p>
<p>For someone like me, who is just learning their first programming language, new to object orientation, and incredibly naive about the power or lack thereof of a given language, I feel blessed to have picked Ruby as my first language to learn. As I have learned Ruby, I&#8217;ve also learned the shortcomings of other languages. I am lucky enough to have a multilingual husband who keeps books like toilet paper in our bathroom, so at any given point I can pick up a little reading material and learn a little Clojure (yeah!!) or C (not so much). I&#8217;ve explored Python and Haskell pretty thoroughly as well as a few other common programming languages. I can&#8217;t argue against any of these languages too much. Why would I? Mostly, as I learn more about other languages, I just feel luckier to have picked Ruby as my devirginizing language. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  I also know it is important to explore the value of other languages. In fact, I know I sometimes need other languages to make the best use of Ruby. There is so much to say about all of this. End interjection (for now.)</p>
<p>The biggest issue for me, as I mentioned earlier, is the fact that ROR is the largest use/implementation of Ruby and the easiest for which you can find tutorials, screencasts, support groups, chatrooms, etc etc. Overwhelmed by ROR, I started using a &#8220;joke&#8221; (literally) framework my friend wrote to get my Ruby programs off the command line and on the web. After dealing with the shortcomings of his babyframework (again, it was written as a &#8220;joke&#8221; and was actually put together as a way to use Ruby as if it were PHP), I started branching out on my own. It became clear to me that, though you can use Ruby in a similar way to PHP using ERB, it&#8217;s not necessarily the best way. I had been working on a dungeon text adventure in Ruby and I was trying to figure out how to make it work via the web using ERB. I was, for the most part, successful. My tech support was limited, but I started to see the parallels of his framework and Sinatra after checking out Sinatra earlier in the week. Enter Sinatra. Things like Rack ran on both the joke framework and Sinatra. I could even use shotgun to run a webserver on my computer. WHOA. All of these things were exposed to me in small doses, and then adding Sinatra to the mix just blew my mind further. Ruby is fuckin&#8217; cool. Noted. And I continued to compute.</p>
<p>When my husband asked me to help with the book search, I was pretty excited. I was so excited to see an actual implementation of a Sinatra-based web app. There was so much Ruby involved!! <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  During my first experience with rails, I was hardly able to figure out where I should even put my Ruby. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Weeks earlier, I had spent time creating a &#8217;sample blog&#8217; in rails, and figuring out the MVC framework. In rails, so much of the work is done for you. A large part of the process is accepting MVC framework, also seen in zend and django in PHP and python, respectively. You don&#8217;t need to be a Ruby expert to do Rails. (But you can be, and you will be better for your knowledge, that&#8217;s for sure. I have never doubted that.) Likewise, I truly believe you could suck at Rails and excel at Ruby. In fact, you&#8217;d probably prefer and have already used Sinatra if this is the case. They are not mutually inclusive. One of my favorite things about Ruby is the power and extensiveness of the language. Frameworks as light as Sinatra give creative freedom and your exposure to Ruby and the web can be vast or minimal&#8211; you can most likely get something to work for you. If you want something big, you&#8217;ll have to build it yourself. On the other hand, larger frameworks provide you an out of the box, large-scale solution that subsequently requires more knowledge and familiarity of the framework <strong>before</strong> you can customize it creatively. </p>
<p>Sinatra allows you a very simple, lightweight framework that requires you build off your own knowledge rather than, as my friend Julio would put it, David&#8217;s skills. Honestly, if you know the scope of your site will be huge, you know your DB infrastructure, and you&#8217;ve been through all of this before, Rails is probably your answer. From what I hear, you&#8217;ll love it, and it&#8217;s worth learning the MVC framework aspects that may be, at first, completely fuckin&#8217; confusing (for me, it&#8217;s slowly coming along after using Sinatra more). However, if you&#8217;re like me, and you wanna start from small potatoes and build it yourself (yeah!!), use Sinatra. I feel like I may be making my way towards Rails, <em>but I may also never get there.</em> I enjoy the freedom of Sinatra, and I&#8217;m not building any gigantic web applications for the time being. Sinatra just rules if you love Ruby, but Rails seems to big and Ruby command line programs aren&#8217;t GUI enough. The web is an excellent agnostic platform for development. So embrace it. I have noticed many programmers are reluctant to do so for various reasons, but Sinatra has opened my eyes to the fact that you can write painless, creative Ruby apps with a little hassle and a lot of fun.</p>
<p>Cheers <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em></em></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-11489803-1");
pageTracker._trackPageview();
} catch(err) {}</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/ruby-on-rails-or-sinatra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Scope Confusion</title>
		<link>http://www.girlwithcomputer.com/stuff/</link>
		<comments>http://www.girlwithcomputer.com/stuff/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 18:11:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/stuff/</guid>
		<description><![CDATA[I ran into some confusion when messing around with a sample program I created that creates new instances of a class Car and names the car. I wanted to store my list of &#8220;funnynames&#8221; in an array and have my naming method grab a random name from the array via my &#8220;name&#8221; method which would [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into some confusion when messing around with a sample program I created that creates new instances of a class Car and names the car. I wanted to store my list of &#8220;funnynames&#8221; in an array and have my naming method grab a random name from the array via my &#8220;name&#8221; method which would be &#8220;initialized&#8221; (using the initialize method) upon creation of each new instance of the Car class. Blahblahblah. So my problem: class variables work for me, but instance variables don&#8217;t! I couldn&#8217;t find much on instance variables, because everything seemed to start talking about instance methods once they mentioned instance variables. It seemed like everyone was reluctant to point out that INSTANCE VARIABLES ARE INVISIBLE!?!?! outside of the class. You can&#8217;t access them outside of the class unless you use an accessor method (easiest) or other method.  If I&#8217;m wrong here, someone correct me. But to my knowledge, that&#8217;s how it works. However, if you store the data you&#8217;d like to access in a class variable, it works! Unfortunately. Since it&#8217;s so easy, but a bad idea, from what I hear.  Inheritance happens. Right? <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And to think&#8230; these three ways to do the same thing in Ruby (minus side effects in the future if I were to use the class variable) aren&#8217;t even the only ways to do this.</p>
<p>It&#8217;s interesting for me that I discovered this basically on my own when developing a simple practice program. Wee! <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre><strong>class Car
  def name
    @funnynames=%w[bob judy mabel wiener]
    puts "Your car's name is #{@funnynames[rand(4)]}!"
  end
end
</strong><em>
#defining array within method </em><strong>

class Car
  @@funnynames=%w[bob judy mabel wiener]
  def name
    puts "Your car's name is #{@@funnynames[rand(4)]}!"
  end
end

</strong><em>#array as a class variable (thus I'm able to access it)</em><strong>

class Car
  @funnynames=%w[bob judy mabel wiener]
  class &lt;&lt; self  </strong><em>#makes the accessor method relevant to the class rather than a single instance</em><strong>
  attr_accessor :funnynames
  def name
    puts "Your car's name is #{Car.funnynames[rand(4)]}!"
  end
end</strong>

<em># Voila!</em> <em>More on this later as I continue to learn the in's and out's</em>
<strong>
</strong></pre>
<p><strong>Currently Computing:</strong> Revisiting my text analyzer with the use of ARGV[] to analyze files via the command line rather than hardcoding in the file to access within the program. SO cool! Then back to more OO sample programs. Rails will happen. I&#8217;m just busy nerding out on Ruby itself for the time being. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Ruby without some rails?</title>
		<link>http://www.girlwithcomputer.com/what-is-ruby-without-some-rails/</link>
		<comments>http://www.girlwithcomputer.com/what-is-ruby-without-some-rails/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 21:54:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/?p=27</guid>
		<description><![CDATA[Why the lucky stiff vanished off the face of the earth by the way&#8230;  Grrr&#8230;
I&#8217;ve been struggling lately with that book of mine. While it is great reading, I feel like I&#8217;m getting a bit stuck. I want to move on to practical applications of Ruby. I thought Shoes might be my answer (I [allegedly] [...]]]></description>
			<content:encoded><![CDATA[<p>Why the lucky stiff vanished off the face of the earth by the way&#8230;  Grrr&#8230;</p>
<p>I&#8217;ve been struggling lately with that book of mine. While it is great reading, I feel like I&#8217;m getting a bit stuck. I want to move on to practical applications of Ruby. I thought Shoes might be my answer (I [allegedly] can develop desktop applications with Ruby!) Nope. _Why took that all with him when he vanished. (Along with Hackety Hack! Which I LOVED and which used Shoes, too!) Ughhh.<strong> (Note: I have since discovered after posting this that many people are still working on his projects, and many are available via github.)</strong> There are ways to use Ruby &#8220;practically&#8221; (or what connotates practically in my head anyways) via various GUIs, but the fact is that Ruby&#8217;s most popular and practical application is Ruby on Rails&#8211; via the web. That&#8217;s just how it is.I&#8217;m not mad about it. I just need a new course of action.</p>
<p>So, as of last night, I&#8217;ve started reading Ruby tutorials all over the web that prepare one for use of RoR. I now know the most important features of Ruby that help one with Rails implementations. Of course, these are all things I learned previously via my Ruby book, but it&#8217;s nice to know which items I will use often and which I can discard as &#8220;unimportant&#8221; temporarily. I foresee my difficulty with Rails being the structure itself, particularly the MVC backbone. I don&#8217;t have a lot of experience with the web, or with programming even. I have limited experience with PHP, CSS, and HTML. But I&#8217;m ready to fuse my skills together and see what happens. I&#8217;m lucky to have help just a few feet away, too. But I try not to bug him too much. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I have not yet created my first Rails application. I&#8217;ll keep you all posted. I can tell you that my first idea for a &#8220;project&#8221; is as ridiculous as it is cute. I am truly a female.  Let&#8217;s see how this goes though. Honestly, I&#8217;m confident this escapade will be interesting. At very least, it will be worth giggling over. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> </p>
<p>P.S. &#8211; Thank you to Alan for explaining some of the more complex features and implementations of OO to me over coffee and toast. I love you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/what-is-ruby-without-some-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>On Learning to Program</title>
		<link>http://www.girlwithcomputer.com/regular-expressions/</link>
		<comments>http://www.girlwithcomputer.com/regular-expressions/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 15:16:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.girlwithcomputer.com/?p=20</guid>
		<description><![CDATA[I&#8217;ve continually breezed through my Ruby book day by day, learning more as I go, and supplementing my knowledge with various aspects of computers with which I am completely dumb. (IE: how did I spend 4+ hours on the computer for the last 10 years of my life and never learn how to navigate the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve continually breezed through my Ruby book day by day, learning more as I go, and supplementing my knowledge with various aspects of computers with which I am completely dumb. (IE: how did I spend 4+ hours on the computer for the last 10 years of my life and never learn how to navigate the command line?!) I blame Windows.</p>
<p>Anyways, my Ruby book has basically become my end-all source for information when it comes to Ruby. In fact, I no longer bug my husband incessantly about the basic in&#8217;s and out&#8217;s because I can just as easily find my answer somewhere in my book&#8211; which I&#8217;m sure, to some degree, alleviates his headache named Ashley. The progression of this particular book is incredibly comprehensive and helpful. I&#8217;d definitely recommend it to anyone (new or existing programmers) interested in learning Ruby. I&#8217;ve caught my husband borrowing it on more than one occasion as a reference guide, too. <img src='http://www.girlwithcomputer.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The first few chapters of the book were pretty simple to digest. Just in case I might have been fooling myself, I decided to read it twice, and some sections three times. I took extensive notes the second and third times. I would say I now have a firm understanding of the basics of object orientation, the Ruby kernel, and the basic syntax and grammar of the Ruby language. I also have a pretty firm footing on the history of Ruby and the basic ideas behind its most popular, current uses (ROR). Every day I try to relate one or more tasks I complete in my daily life to something for which I could write a program (usually something that involves manual repetition.) Then, I think about how I&#8217;d get started. Sometimes I start computing the idea, and move forward until I don&#8217;t know what to do next; other times I just brainstorm how the knowledge I have so far would apply to executing my idea. Basically, I&#8217;m trying to get out of &#8220;idea world&#8221; and  into the mindset of a programmer (though I know the best programmers must be the ones who have a firm footing in both of these realms). It sounds ridiculous when I write out my thought process, but my reasoning is simple.<em> I&#8217;m good with ideas, but I would be stuck in &#8220;idea world&#8221; without any clue of how to practically apply the things I&#8217;m reading if I didn&#8217;t spend time each day trying to &#8220;think like a programmer.&#8221; </em></p>
<p><strong>Currently Computing: </strong>I am working on a text analyzer as my first &#8220;complete&#8221; Ruby program. I&#8217;m struggling a bit with some of the more intermediate forms of regular expressions so I&#8217;m reviewing that for the 5th or 6th time. I should be on to the next project shortly, where I will be learning more in depth features of Ruby&#8217;s object orientation abilities and creating a program that utilizes these features in depth. (Up to now my experience with object orientation is limited to simple people and pet examples.) Exciting! <em><br />
</em></p>
<p><em><br />
</em></p>
<p><em><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.girlwithcomputer.com/regular-expressions/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

