This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| # Write the tag class and the methods to make the specs pass | |
| describe Tag do | |
| def tag(name, options = {}) | |
| Tag.new(name, options).show | |
| end | |
| it "instantiate itself" do | |
| Tag.new(:p).should_not be_nil |
| # Objective: | |
| # Rewrite each of the methods, espressions or statements into better | |
| # readable and idiomatic Ruby code | |
| def getDnaLab(lab_name) | |
| DnaLab.get_all.each do |lab| | |
| if lab.name == lab_name | |
| return lab | |
| end |
| # The goal is take type specific conditionals out of a class and use polymorphism to let each class handle their own responsibilities | |
| class Animal | |
| def initialize(type) | |
| @type = type | |
| end | |
| def eat | |
| "eating... nom nom" |
| ############################################################################## | |
| # Add specs here to help drive functionality in the Post class | |
| #post_spec.rb | |
| require 'post' | |
| describe Post do | |
| it "should exist :)" do |
| # post.rb ############ | |
| module Commentable | |
| attr_accessor :comments | |
| def setup_comments | |
| @comments ||= [] | |
| end | |
| def add_comment(comment) |
| # Objective: | |
| # Rewrite each of the methods, espressions or statements into more into better | |
| # readable and idiomatic Ruby code | |
| def getDnaLab(lab_name) | |
| DnaLab.all.each do |lab| | |
| if lab.name == lab_name | |
| return lab | |
| end |
| require 'rubygems' | |
| require 'highline/import' | |
| require 'highline_menus_methods' #method definitions defined in external file | |
| line = "="*72 | |
| puts line | |
| say "Welcome to my math program" | |
| #highline menu stuff... | |
| loop do #setup infinite loop |
| require 'rubygems' | |
| require 'pivotal-tracker' | |
| require 'highline/import' | |
| HighLine.track_eof = false | |
| def story_filter(chosen_state) | |
| lambda {|story| story.owned_by == @name && story.current_state == chosen_state} | |
| end |
| require 'rubygems' | |
| require 'twitter' | |
| require 'highline/import' | |
| username = ask("Please enter twitter name") | |
| unless username.empty? | |
| size = 50 #limit to 50 followers arbitrarily |