Created
November 24, 2010 16:16
-
-
Save paulbjensen/713900 to your computer and use it in GitHub Desktop.
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 'rubygems' | |
require 'steak' | |
require 'cucumber' | |
class Opinion | |
def self.give(topic, subjects) | |
case topic | |
when "which is better?" | |
if self.is_a_code_bastard? | |
subjects.sort_by(|x| x.lines_of_code).first | |
elsif self.hates_clients? | |
subjects.sort_by{ | |
|s| s.is_perversely_unintelligible_to_everyone_except_developers? | |
}.reverse.first | |
else | |
self.would_rather_toss_a_code_equivalent_of_a_coin_to_decide(subjects) | |
end | |
end | |
end | |
def self.is_a_code_bastard? | |
line_count = `wc -l #{__FILE__}` | |
line_count.to_i <= 10 | |
end | |
def self.hates_clients? | |
self.was_asked_to_move_some_text_to_the_left_by_1_pixel? || | |
self.was_asked_to_support_ie6? || | |
self.was_treated_to_clients_version_of_good_cop_bad_cop? || | |
self.is_in_a_bad_mood? || | |
self.is_a_misanthrope? | |
end | |
def self.would_rather_toss_a_code_equivalent_of_a_coin_to_decide(subjects) | |
subjects[rand(subject.size)] | |
end | |
end | |
Opinion.give("which is better?", Steak, Cucumber) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment