So, who is this guy?
Visit http://www.napcs.com/
http://www.snippetstash.com/
http://www.feelmyskills.com/
http://www.webdesignfordevelopers.com
A talk about shoes would be completely inappropriate at a code camp. So we’re not talking about these kinds of shoes. Although, a search for shoes on Google will turn up lots of stuff like this.
We’re talking about Shoes, a cross-platform framework for making GUI apps, using the Ruby language.
It’s also incredibly easy to learn.
One of the nice things about Ruby is that it strives to be easy to read. Here, we’re declaring some variables and setting values.
Like most languages, you’ve got constants, local variables, and instance variables. The convention in Ruby is to use all capital letters for constants, but anything that starts with a capital letter is considered constant.
You can actually change values of constants at runtime, but you will get a warning about that.
Instance variables get the @ sign.
Anyone know what dynamically typed is?
What’s the opposite of dynamically typed?
You’ll get a runtime error because you can’t add a string to a number
The to_s method converts many types of objects to strings.
You can embed any expression this way and it will automatically cast the value to a string, even if it’s a null value.
def is so much nicer than function.
There’s no such thing as a primitive in Ruby. Even a string or an integer is an object.
With methods, if it’s not explicit with a return, then the return value is the value of the last statement.
1 is true. 0 is not false.
The “java” way. This is on the way out because it’s stupid. Here we’re declaring instance variables, getters, and setters. Essentially creating properties.
attr_accessor creates variables, getters, and setters.
Metaprogramming!
They’re everywhere.
Square brackets denote hashes.
Curly braces and => are for hashes.
Hashrocket.
Only one parameter which is a hash. Hashes are amazing because you can actually send the parameters into a method in any order, and it’s nicely self-documenting. No referencing the api to figure out which parameter is the width.
Blocks are like closures or anonymous fuctions
We can use them for looping instead of having to track an array or hash position.
This is a standard pattern in Ruby classes.
Obligatory LOLCAT is obligatory!
Parenthesis are optional in many cases, especially when it’s obvious.
you’re supposed to BOO!
and no, this doesn’t excuse the bad joke.
Use the .text method to grab the text from the textbox.
The @names section contains the names we add, and names get added when we click the button.
Stacks and flows can be cleared as well. Clear can take a block which you can use to place new content in the stack or flow.
So instance variables are isolated.
We can use a nice MVC-style structure here. Notice that we can wrap blocks in methods so we can easily call them.
The video player plays mp3s, oggs, avis, movs, flvs and more.
There are hundreds of libraries out there for doing pretty much anything. Twitter, Youtube, Flickr, Last.fm, and anything in between.
When the app starts, these libraries get installed to the user’s home directory.
Accessing standard dialogs and the clipboard is pretty simple.
Either check it out with git or click the download link and unzip the package.