Class: DeviceControl::Flexstat
Instance Attribute Summary
Attributes inherited from Controller
#measure, #setpoint
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Controller
#initialize, #input=, #to_s
Methods included from Updateable
#update
Class Method Details
.cold_val(hot_val) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/device_control.rb', line 117
def self.cold_val(hot_val)
case hot_val
when true, false
!hot_val
when 0,1
hot_val == 0 ? 1 : 0
when Numeric
0
when :on, :off
hot_val == :on ? :off : :on
else
raise "#{hot_val.inspect} not recognized"
end
end
|
Instance Method Details
#initalize(hot_val: false, cold_val: nil) ⇒ Object
132
133
134
135
|
# File 'lib/device_control.rb', line 132
def initalize(hot_val: false, cold_val: nil)
@hot_val = hot_val
@cold_val = cold_val.nil? ? self.class.cold_val(hot_val) : cold_val
end
|
#output ⇒ Object
137
138
139
|
# File 'lib/device_control.rb', line 137
def output
super ? @cold_val : @hot_val
end
|