Although you're free to use any editor we recommend Sublime. Here's how to get the most out of it
Once you've installed Sublime there's a few things you should do to get things set up properly:
{ | |
"env":{ | |
"PATH":"${HOME}/.rvm/bin:${PATH}" | |
}, | |
"cmd": ["rvm-auto-ruby", "$file"], | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.ruby" | |
} |
{ | |
// This is the ruby default | |
"tab_size": 2, | |
// Set to true to insert spaces when tab is pressed | |
"translate_tabs_to_spaces": true, | |
// This shows all your whitespace, including spaces and tabs | |
// helps keep code clean and properly indented! | |
"draw_white_space": "all", |
Although you're free to use any editor we recommend Sublime. Here's how to get the most out of it
Once you've installed Sublime there's a few things you should do to get things set up properly:
This is a brief introduction into the world of web development and Ruby. To view all the different gems listed by popularity check out the Ruby Toolbox.
def vader(evil = false) | |
# guard clause | |
return "something else" if evil == "luke" | |
# implicit return, last line executed | |
if evil | |
"i am your father and I hate you" | |
else | |
"i am your father and i love you" | |
end |
# You can loop through a range | |
(1..10).each {|a| puts a } | |
first_ten = (1..10).to_a | |
# You can convert it into an array | |
puts first_ten.inspect | |
puts "selecting odd numbers" |
def do_some_maths | |
puts yield(10) | |
puts yield(20) | |
end | |
do_some_maths do |num| | |
num * 20 | |
end | |
do_some_maths do |number| |
#create your own methods | |
#create a method with one argument, and print it out | |
#create a method with two arguments | |
#create a method with one argument, which by default is nil | |
#create a method that returns two values, depending on if an argument is true or false | |
#take this hash, and use it to make this string. Make sure you use the hash twice, | |
#and use string interpolation i.e. "A string #{variable}" | |
hash = {:dario => "Dario", :leo => "Leo"} |
- Copy setup.zip to your Downloads folder | |
- Double click the folder to unzip the folder | |
- Open the folder, and then once inside: | |
require 'minitest/autorun' | |
require 'mocha/setup' | |
require './lib/dice' | |
class DiceTest < MiniTest::Unit::TestCase | |
def setup | |
@one_dice = Dice.new(1) | |
@two_dice = Dice.new(2) | |
end |