Week 4, day 1

It's Easter Monday and it's a holiday! Yay! Not really, there's work to be done...
Finished up my 'final' version of RPS this morning, incorporating the option to play RPS-Lizard-Spock (RPSLS) and all the logic required for it.
Looking back at it now I feel like I got very lucky with things just working with as little headache as possible, and most of my errors came from typos and syntax.
My RPS challenge Github repo
I'm pretty happy with my Ruby code, less confident about my HTML and CSS but I'm just glad I've caught up with the course so far and look forward to some valuable feedback from my code review tomorrow.

1 class CPU
2   def choice
3     %w(Rock Paper Scissors).sample
4   end
5 
6   def choice_rpsls
7     %w(Rock Paper Scissors Lizard Spock).sample
8   end
9 end

That's all I used to generate a random selection from the computer player, 'choice' for regular RPS and 'choice_rpsls' for the Lizard-Spock variant of the game.

 1 class Decide
 2   def initialize
 3     @beats = { "Rock" => %w(Paper Spock), "Paper" => %w(Scissors Lizard), "Scissors" => %w(Rock Spock), "Lizard" => %w(Scissors Rock), "Spock" => %w(Paper Lizard) }
 4   end
 5 
 6   def make p1, p2
 7     return "tie" if p1 == p2
 8     return "win" if @beats[p2].include?(p1)
 9     "lose"
10   end
11 end

And that's all it takes to determine the outcome of a game.

Spent the afternoon getting a bit of sun and doing a bit of shopping, then got a head start on the coming week's database exercises with PostgreSQL. Most seniors I've spoken with say this was their favourite week so it's got a lot to live up to, but I feel confident about handling databases.
Our accrued knowledge is definitely showing, I can effortlessly glide through troubleshooting most of the early errors I come across in Ruby and Rspec.
I'm also getting used to Capybara/Cucumber tests.

Written on April 6, 2015