lib/stf/model/device.rb in stf-client-0.2.6 vs lib/stf/model/device.rb in stf-client-0.3.0.pre.rc.12
- old
+ new
@@ -6,10 +6,36 @@
def getKeys
getKeysNextLevel('', self)
end
- def checkFilter(filter)
+ # more pessimistic decision
+ def healthy_for_connect?(pattern)
+ return true if pattern.nil?
+ health = healthy?(pattern)
+ ppp = pattern.split(',')
+ ppp.each do |p|
+ health &&= getValue('battery.temp').to_i < 30 if ['t', 'temp', 'temperature'].include? p
+ health &&= getValue('battery.level').to_f > 30.0 if ['b', 'batt', 'battery'].include? p
+ end
+ health
+ end
+
+ def healthy?(pattern)
+ return true if pattern.nil?
+ ppp = pattern.split(',')
+ health = true
+ ppp.each do |p|
+ health &&= getValue('battery.temp').to_i < 32 if ['t', 'temp', 'temperature'].include? p
+ health &&= getValue('battery.level').to_f > 20.0 if ['b', 'batt', 'battery'].include? p
+ health &&= getValue('network.connected') if ['n', 'net', 'network'].include? p
+ health &&= getValue('network.type') == 'VPN' if ['vpn'].include? p
+ health &&= getValue('network.type') == 'WIFI' if ['wifi'].include? p
+ end
+ health
+ end
+
+ def checkFilter?(filter)
return true if filter.nil?
key, value = filter.split(':', 2)
getValue(key) == value
end