class DBus::Data::Boolean
Boolean: encoded as a {UInt32} but only 0 and 1 are valid.
Constants
- FORMAT
Public Class Methods
Source
# File lib/dbus/data.rb, line 221 def self.from_raw(value, mode:) validate_raw!(value) value = value == 1 return value if mode == :plain new(value) end
Source
# File lib/dbus/data.rb, line 235 def initialize(value) value = value.value if value.is_a?(self.class) super(value ? true : false) end
Accept any value, store its Ruby truth value (excepting another instance of this class, where use its {#value}).
So new(0).value is true. @param value [::Object,DBus::Data::Boolean]
Calls superclass method
DBus::Data::Base::new
Source
# File lib/dbus/data.rb, line 215 def self.validate_raw!(value) return if [0, 1].member?(value) raise InvalidPacketException, "BOOLEAN must be 0 or 1, found #{value}" end
Public Instance Methods
Source
# File lib/dbus/data.rb, line 241 def marshall(endianness) int = value ? 1 : 0 [int].pack(UInt32.format[endianness]) end
@param endianness [:little,:big]