Created
August 15, 2013 22:45
-
-
Save jcsalterego/6245651 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Employee < Person | |
| include SalaryUtils | |
| attr_accessor :annual_salary | |
| def weekly_salary | |
| hourly_rate(annual_salary) * 40 | |
| end | |
| end |
This file contains hidden or 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
| class Person | |
| attr_accessor :name | |
| end |
This file contains hidden or 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
| module SalaryUtils | |
| HOURS_PER_YEAR = 52*40 | |
| def hourly_rate(salary) | |
| salary.to_f / HOURS_PER_YEAR | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment