Class: DeviceControl::Device
- Inherits:
-
Object
- Object
- DeviceControl::Device
- Includes:
- Updateable
- Defined in:
- lib/device_control.rb
Overview
A Device is like a heater. It has a control knob, maybe on/off or perhaps a variable control. Its output (maybe on/off) depends on the control knob.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#knob ⇒ Object
readonly
Returns the value of attribute knob.
Instance Method Summary collapse
-
#initialize ⇒ Device
constructor
A new instance of Device.
- #input=(val) ⇒ Object (also: #knob=)
- #output ⇒ Object
- #to_s ⇒ Object
Methods included from Updateable
Constructor Details
#initialize ⇒ Device
Returns a new instance of Device.
31 32 33 |
# File 'lib/device_control.rb', line 31 def initialize @knob = 0.0 end |
Instance Attribute Details
#knob ⇒ Object (readonly)
Returns the value of attribute knob.
29 30 31 |
# File 'lib/device_control.rb', line 29 def knob @knob end |
Instance Method Details
#input=(val) ⇒ Object Also known as: knob=
35 36 37 |
# File 'lib/device_control.rb', line 35 def input=(val) @knob = val.to_f end |
#output ⇒ Object
40 41 42 |
# File 'lib/device_control.rb', line 40 def output @knob # do nothing by default end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/device_control.rb', line 44 def to_s format("Knob: %.3f\tOutput: %.3f", @knob, self.output) end |