Skip to content

Instantly share code, notes, and snippets.

@nysalor
Created July 27, 2012 11:21
Show Gist options
  • Save nysalor/3187465 to your computer and use it in GitHub Desktop.
Save nysalor/3187465 to your computer and use it in GitHub Desktop.
TDD sample production code
class AgeCalc
attr_accessor :birthday
def age
@age ||= calculate_age
end
def calculate_age
if @birthday
(Time.now.strftime("%Y%m%d").to_i - @birthday.strftime("%Y%m%d").to_i) / 10000
else
nil
end
end
def increment_age
@age += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment