Skip to content

Instantly share code, notes, and snippets.

@bragboy
Created December 31, 2015 12:43
# 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