Class: Device
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.
30 31 32 |
# File 'lib/device_control.rb', line 30 def initialize @knob = 0.0 end |
Instance Attribute Details
#knob ⇒ Object (readonly)
Returns the value of attribute knob.
28 29 30 |
# File 'lib/device_control.rb', line 28 def knob @knob end |
Instance Method Details
#input=(val) ⇒ Object Also known as: knob=
34 35 36 |
# File 'lib/device_control.rb', line 34 def input=(val) @knob = val.to_f end |
#output ⇒ Object
39 40 41 |
# File 'lib/device_control.rb', line 39 def output @knob # do nothing by default end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/device_control.rb', line 43 def to_s format("Knob: %.3f\tOutput: %.3f", @knob, self.output) end |