This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User | |
| MIN_RANK = -8 | |
| MAX_RANK = 8 | |
| RANKS = (MIN_RANK..MAX_RANK).to_a - [0] | |
| REWARDS = {-2 => 0, -1 => 1, 0 => 3} | |
| attr_reader :rank, :progress | |
| def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Cell | |
| attr_accessor :value | |
| def empty? | |
| @value.nil? | |
| end | |
| def possible_values(neighbours) | |
| (1..9).to_a - neighbours |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe Array do | |
| it 'should know its size' do | |
| array = [1,2,3,4] | |
| array.size.should eq(4) | |
| end | |
| it 'should be created with default value' do | |
| array = Array.new(3) { "fizz" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PoliteMailer | |
| def send(to) | |
| message = %Q[message for #{to} | |
| Hello, | |
| How are you today? | |
| I just had a great idea: | |
| #{yield} | |
| Hope to hear from you soon | |
| Best regards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Bitcoin | |
| def initialize | |
| @observers = Hash.new | |
| # {:coin_mined => [handler_block1, handler_block2]} | |
| end | |
| def mine! | |
| 100.times do |i| | |
| trigger(:coin_mined, i) if i % 13 == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'minitest/autorun' | |
| require '../lib/tic_tac_toe' | |
| class TicTacToeTest < Minitest::Test | |
| # the board is represented as a string of rows, e.g. | |
| # X | | X | |
| # --------- | |
| # 0 | 0 | X | |
| # --------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AirportTest | |
| def setup | |
| @airport = Airport.new | |
| end | |
| def test_plane_can_land | |
| end | |
| # A plane currently in the airport can be requested to take off. |