Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
# COMMUNITY CHALLENGE | |
# | |
# How would you test this Quiz#problem method? No mocks/stubs allowed. | |
# | |
# (Here's @seacreature's take) | |
class Quiz | |
def initialize(input = STDIN, output = STDOUT) | |
@input = input | |
@output = output |
This file contains 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 RAAWS | |
ONE_NECESSARY_SEARCH_PARAM =%w< | |
Actor Artist AudienceRating Author | |
Brand BrowseNode Composer Conductor CityDirector | |
Keywords Manufacturer MusicLabel Neighborhood | |
Orchestra Power Publisher TextStream Title> | |
class ItemOperation < Operation | |
def self.lookup(item_id, index=nil, &block) |
This file contains 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
IMAGE_TYPES = %w( image/jpeg image/png image/pjpeg image/x-png image/gif ) | |
validates_attachment_content_type :image, :content_type => IMAGE_TYPES |
This file contains 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
acc += (e.is_a?(Hash) && e.has_key?(:colspan)) ? e[:colspan] : 1 | |
cell_text = cell.is_a?(Hash) ? cell[:text] : cell.to_s | |
if cell.is_a?(Hash) && cell[:colspan] | |
text = e.is_a?(Hash) ? e[:text] : e.to_s | |
width = if e.is_a?(Hash) && e.has_key?(:colspan) |
This file contains 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
## Extract Class (http://refactoring.com/catalog/extractClass.html) | |
class Person | |
attr_accessor :name, :office_area_code, :office_number | |
def telephone_number | |
[office_area_code, office_number].join('-') | |
end | |
end |
This file contains 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 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 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" | |
# inspired by some code from Chris Wanstrath (shared w. me by Ryan Smith) | |
# https://gist.github.com/25455 | |
# | |
# heavily modified by Gregory Brown at this point.. | |
def context(*args, &block) | |
return super unless (name = args.first) && block |
This file contains 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 Circuitry | |
extend self | |
def []=(name, definition) | |
circuits[name] = definition | |
end | |
def [](name) | |
circuits[name] | |
end |
OlderNewer