Module: Ansible::ZWave::ValueType_Bool

Defined in:
lib/ansible/zwave/openzwave/types/valuetype_bool.rb

Overview

boolean value type for OpenZWave

Instance Method Summary collapse

Instance Method Details

#as_canonical_valueObject



43
44
45
46
47
48
49
50
# File 'lib/ansible/zwave/openzwave/types/valuetype_bool.rb', line 43

def as_canonical_value()
    return (
        case 
        when [TrueClass, FalseClass].include?(current_value.class) then current_value
        else false
        end
    )
end

#explainObject

return a human-readable representation of a ZWave frame



65
66
67
68
# File 'lib/ansible/zwave/openzwave/types/valuetype_bool.rb', line 65

def explain
    puts "cv = #{@current_value}"
    return(@current_value? "ON":"OFF")
end

#read_operationObject

define type-specific OZW::Manager API calls



33
34
35
# File 'lib/ansible/zwave/openzwave/types/valuetype_bool.rb', line 33

def read_operation 
    return :GetValueAsBool 
end

#to_protocol_value(new_val) ⇒ Object

map any ruby value to boolean



53
54
55
56
57
58
59
60
61
62
# File 'lib/ansible/zwave/openzwave/types/valuetype_bool.rb', line 53

def to_protocol_value(new_val)
    return (
        case
        when [Fixnum].include?(new_val.class) then (new_val > 0)
        when [TrueClass, FalseClass].include?(new_val.class) then new_val
        when new_val.nil? then false
        else true
        end
    )
end

#write_operationObject



38
39
40
# File 'lib/ansible/zwave/openzwave/types/valuetype_bool.rb', line 38

def write_operation
    return :SetValue_Bool
end