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" | |
| class RangeTest < Minitest::Test | |
| def test_ranges | |
| assert 2.between? 0,5 | |
| assert (0..5).include? 2 | |
| assert (0..5).include? 0 | |
| assert (0..5).include? 5 | |
| assert (0...5).include? 0 | |
| refute (0...5).include? 5 |
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 "continuation" | |
| # via http://c2.com/cgi/wiki?AmbInRuby | |
| class Amb | |
| def initialize | |
| @paths = [] | |
| end | |
| def choose choices | |
| choices.each do |choice| |
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 ImmutableObject | |
| def initialize | |
| freeze | |
| end | |
| end | |
| class BaseImmutableStruct < ImmutableObject | |
| attr_reader :members | |
| def initialize(members) |
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 ImmutableObject | |
| def initialize | |
| freeze | |
| end | |
| end | |
| class BaseImmutableStruct < ImmutableObject | |
| attr_accessor :members | |
| def initialize(members) |
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
| Jan 24 14:10:31 lambda System Preferences[28901]: CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 7. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug. |
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
| #!/usr/bin/env ruby -w | |
| require 'benchmark/bigo' | |
| require 'rubyfish' | |
| require_relative 'typo_suggestor' | |
| require_relative 'levenshtien_suggestion' | |
| require_relative 'metaphone_suggestion' | |
| Benchmark.bigo do |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
| $ rake spec | |
| rake aborted! | |
| Don't know how to build task 'test:prepare' | |
| Tasks: TOP => spec | |
| (See full trace by running task with --trace) |
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
| $rspec spec | |
| Warning: you should require 'minitest/autorun' instead. | |
| Warning: or add 'gem "minitest"' before 'require "minitest/autorun"' | |
| From: | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require' | |
| /Users/scott/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/test/unit/assertions.rb:1:in `<top (required)>' |
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 "date" | |
| class Person | |
| CURRENT_YEAR = ->{ Date.new.year } | |
| attr_reader :birthday | |
| def initialize(attributes={}) | |
| @birthday = attributes.fetch(:birthday) | |
| 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
| require "minitest/autorun" | |
| require "date" | |
| class Person | |
| attr_reader :birthday | |
| def initialize(attributes={}) | |
| @birthday = attributes.fetch(:birthday) | |
| end |