Skip to content

Instantly share code, notes, and snippets.

@bragboy
Created December 31, 2015 12:43
Show Gist options
  • Select an option

  • Save bragboy/2256132c3f2a693014ee to your computer and use it in GitHub Desktop.

Select an option

Save bragboy/2256132c3f2a693014ee to your computer and use it in GitHub Desktop.
# 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