We will improve our programming skills by meeting weekly and working on programming stuff.
- ruby
- ruby on rails
- rspec, cucumber
- coffeescript
- git: forking on github
- unix/linux command line
- development tools / IDEs: RubyMine, vim, sublime text
- managing / setting up a webserver
Who: Stephen
When:
Where: DevCave
What: Ruby and RTanque: Battle day
Prep:
ruby-doc.org ::: Bookmark it!
If you didn't do the quick start (below) before, do it for this time.
Fork steptan's RTanque github repo so you can share your bot via pull request
[email protected]:steptan/RTanque.git
come ready to battle
Who: Stephen
When: Tue Mar 5 6:30 AM 2013
Where: DevCave
What: Ruby and RTanque
Prep:
Quick Start: (run from the command line)
mkdir rtanque; cd rtanque
echo '1.9.3' > .ruby-version
bundle init
echo "gem 'rtanque'" >> Gemfile
bundle
bundle exec rtanque new\_bot my\_bot
bundle exec rtanque start bots/my\_bot sample\_bots/keyboard sample\_bots/camper:x2
Drive the Keyboard bot with asdf. Aim/fire with the arrow keys
http://awilliams.github.com/RTanque/
- Why doesn't 'git status' complain about the rtanque subfolder?
- ANSWER: You have the folder "/rtanque/*" listed in the .gitignore file. first:Miles
- Who has forked this git repo on github?
- COOLEST FIRST:
Ruby basics
- everything in Ruby is an Object
- Object are created from Classes
- every Class extends another class, all the way back to Object
For example, numbers are objects, too
arithmetic operators are just method calls
so + is a method on the Number class
3 + 3 #(is the same as)
3.+(3)
- Class-wide values accessed by appending :: to class name
- Static constants: Math::PI
- Classes can be "instantiated" to create "instances" which are Object
- Variables point to Object
- Instance variables persist across method calls and have a @ prepended @lives = @lives - 1
- ruby constructor: initialize
- each time a Class is instantiated
- a new Object is born
- its initialize method is called
- initialize method takes 1 argument
def initialize(blah)
@radar = 0.0
end
- every Class inherits from the Object class
- ruby returns the last thing in your method
- duck typing
- + is actually a method (same for *, -, / etc)
- every method returns the last thing
- irb is a great way to quickly test stuff and learn Ruby from the command line
__ Try this in irb:__
you can concatenate Strings in Ruby
"Hi," + " there"
you cannot do this:
5 + " little monkeys"
why not? duck typing. Ruby finds 5, wants to do arithmetic
5 + 5
this works:
5.to_s + " little monkeys"
because now Ruby can concatinate 2 Strings: "5" and " little monkeys"
- to force a line break, end a line with two spaces
- to make a link,
- put the text of the link in square braces
- put the link inside parenthesis