Created
December 31, 2015 12:43
-
-
Save bragboy/2256132c3f2a693014ee 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
| # models/instrument.rb | |
| class Instrument | |
| attr_accessor :units | |
| def initialize(status, units) | |
| @status = status | |
| @units = units | |
| end | |
| def turn_on | |
| @status = STATUS_ON | |
| end | |
| def turn_off | |
| @status = STATUS_OFF | |
| end | |
| def status | |
| @status | |
| end | |
| def power_consumption | |
| (@status == STATUS_ON)? @units : 0 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment