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
| # Task: Implement the rcat utility and get these tests to pass on a system | |
| # which has the UNIX cat command present | |
| # To see Gregory Brown's solution, see http://github.com/elm-city-craftworks/rcat | |
| # Feel free to publicly share your own solutions | |
| rrequire "open3" | |
| working_dir = File.dirname(__FILE__) | |
| gettysburg_file = "#{working_dir}/data/gettysburg.txt" |
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 A; end; A.new(:foo, :bar) | |
| => #<A:0x00000100b6f9a8> | |
| >> RUBY_VERSION | |
| => "1.9.2" | |
| >> class A; end; A.new(:foo, :bar) | |
| ArgumentError: wrong number of arguments(2 for 0) | |
| from (irb):1:in `initialize' | |
| from (irb):1:in `new' | |
| from (irb):1 |
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
| # Looking to reduces rows of board game data to | |
| # primitives (for eventual JSON output). | |
| # each cell can be either unoccupied, or occupied by N | |
| # armies of a given color. What data format do you prefer, | |
| # and why? | |
| #---------------------------------------------------------- | |
| # 1) nil indicates empty territory | |
| [[:white, 2], nil, [:black, 3]] |
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
| Stack Wars is an abstract board game played on a two dimensional grid, similar | |
| to a Chess or Go board. The game is currently still being play tested / | |
| balanced, but the rules below should give you enough to try it out on your own. | |
| == Board layout + setup | |
| The board represents a battlefield that two players must | |
| fight for control over, with the goal of invading each other's bases. The ASCII | |
| representation below shows a standard 9x9 grid representing the battlefield. |
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
| # is this evil, weird, or awesome? | |
| module ExtendedExtend | |
| def extend(*args, &block) | |
| if args.empty? | |
| super(Module.new(&block)) | |
| else | |
| super | |
| end | |
| end |
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
| # Given | |
| Match /^I have entered (\d+) into the calculator$/ do |n| | |
| @calculator ||= Calculator.new | |
| @calculator.push(n.to_i) | |
| end | |
| # When | |
| Match /^I press add$/ do | |
| @result = @calculator.add |
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
| Feature: Addition | |
| Scenario: Add two numbers | |
| Given I have entered 70 into the calculator | |
| And I have entered 50 into the calculator | |
| When I press add | |
| Then the result should be 120 |
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
| # coding: binary | |
| class BMP | |
| class Writer | |
| PIXEL_ARRAY_OFFSET = 54 | |
| BITS_PER_PIXEL = 24 | |
| DIB_HEADER_SIZE = 40 | |
| PIXELS_PER_METER = 2835 # 2835 pixels per meter is basically 72dpi | |
| def initialize(width, height) |
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
| # coding: binary | |
| class BMP | |
| class Reader | |
| PIXEL_ARRAY_OFFSET = 54 | |
| BITS_PER_PIXEL = 24 | |
| DIB_HEADER_SIZE = 40 | |
| def initialize(bmp_filename) | |
| File.open(bmp_filename, "rb") do |file| |
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
| it "implements ROT" do | |
| execute %w[ | |
| :foo | |
| :bar | |
| :baz | |
| :foobar | |
| :quux | |
| ROT | |
| ] | |