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
| afsasf |
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
| def reduce(initial_value, &block) | |
| reduce_fun = fun(element, acc) { block(acc, element) } | |
| erl.lists.foldl(reduce_fun, initial_value, self) | |
| 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 "rubygems" | |
| require "sinatra" | |
| get "/next" do | |
| tell_itunes "next track" | |
| end | |
| get "/previous" do | |
| tell_itunes "previous track" | |
| 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
| module Measurable | |
| def area | |
| width * height | |
| end | |
| attr_reader :width, :height | |
| end | |
| class Rectangle | |
| include Measurable |
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
| def hello | |
| "Hello World" | |
| 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
| def path_to_hotel?(day) | |
| car_rented?(day) || hotel_near_destination?(day) | |
| 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
| def distance_to_hotel(day, index) | |
| case | |
| when index >= @grid.size - 1 | |
| '' | |
| when day[:lodgings].empty? | |
| UNKNOWN_DISTANCE | |
| when overnight_transport?(day) | |
| OVERNIGHT_TRANSPORT_LABEL | |
| when day[:arrive] | |
| day[:arrive].distance_from(hotel_location(day) |
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 Array | |
| def group_by | |
| hash = Hash.new { |h,k| h[k] = [] } | |
| each { |i| hash[yield(i)] << i } | |
| hash | |
| 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
| module PlayingCards | |
| class Card | |
| attr_accessor :rank, :suit | |
| def initialize(a_rank, a_suit) | |
| @rank = parse_rank a_rank | |
| @suit = parse_suit a_suit | |
| 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_relative "../lib/ivory_tower" | |
| require_relative "shared/allowed_units" | |
| # adopted from: https://gist.github.com/839034 | |
| def context(*args, &block) | |
| return super unless (name = args.first) && block | |
| context_class = Class.new(MiniTest::Unit::TestCase) do | |
| class << self |