Skip to content

Instantly share code, notes, and snippets.

@kblake
Created September 24, 2010 20:07
Show Gist options
  • Save kblake/595950 to your computer and use it in GitHub Desktop.
Save kblake/595950 to your computer and use it in GitHub Desktop.
# 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
end
return nil
end
def getLabDisplayName(labName)
for dnaLab in DnaLab.all
if dnaLab.name == labName
return dnaLab.display_name
end
end
return ""
end
#############################################################
user_id = nil
if comments
if comments.first
if comments.first.user
user_id = comments.first.user.id
end
end
end
#############################################################
breakfast = call_to_unknown_method
if breakfast == nil
breakfast = "bacon and egss"
end
#############################################################
if val == 1 || val == 12 || val == 42 || val == 99 || val == 35
puts "woo hoo!"
end
#############################################################
def stringify_array(an_array)
a_string = ""
for element in an_array
if a_string.size > 0
a_string += ", "
end
a_string += element.to_s
end
return a_string
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment