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
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 |
# 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 |
# post.rb ############ | |
module Commentable | |
attr_accessor :comments | |
def setup_comments | |
@comments ||= [] | |
end | |
def add_comment(comment) |
############################################################################## | |
# Add specs here to help drive functionality in the Post class | |
#post_spec.rb | |
require 'post' | |
describe Post do | |
it "should exist :)" do |
# 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" |
# 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 |
# 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 |
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
.bling { color: golden; border: 1px solid sparkle; } |
>> foo = proc { bar } | |
=> #<Proc:0x0000000101c444b8@(pry):1> | |
>> foo.call | |
NameError: undefined local variable or method `bar' for #<Object:0x1001dc288> | |
from (pry):1 | |
>> def bar | |
>> "bar" | |
>> end |