Support negation of conditions by prefixing them with "^"
This commit is contained in:
parent
4abf514b90
commit
6c78b621c4
8
hued
8
hued
|
@ -124,8 +124,13 @@ class Hued
|
|||
return true if @conditions.empty?
|
||||
|
||||
@conditions.map do |cond|
|
||||
if cond.is_a? Hash
|
||||
cond_negate = false
|
||||
res = if cond.is_a? Hash
|
||||
cond_name, cond_value = cond.to_a.first
|
||||
if cond_name[0] == "^"
|
||||
cond_negate = true
|
||||
cond_name = cond_name[1..-1]
|
||||
end
|
||||
case cond_name
|
||||
when "from"
|
||||
Time.now >= Chronic.parse(cond_value)
|
||||
|
@ -137,6 +142,7 @@ class Hued
|
|||
else
|
||||
@log.warn "Unknown condition type/form #{cond.inspect}"
|
||||
end
|
||||
cond_negate ? !res : res
|
||||
end.all?
|
||||
end
|
||||
|
||||
|
|
Reference in New Issue