class DBus::Data::Boolean
Boolean: encoded as a {UInt32} but only 0 and 1 are valid.
Constants
- FORMAT
Public Class Methods
alignment()
click to toggle source
# File lib/dbus/data.rb, line 206 def self.alignment 4 end
format()
click to toggle source
# File lib/dbus/data.rb, line 210 def self.format FORMAT end
from_raw(value, mode:)
click to toggle source
# File lib/dbus/data.rb, line 220 def self.from_raw(value, mode:) validate_raw!(value) value = value == 1 return value if mode == :plain new(value) end
new(value)
click to toggle source
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
# File lib/dbus/data.rb, line 234 def initialize(value) value = value.value if value.is_a?(self.class) super(value ? true : false) end
type_code()
click to toggle source
# File lib/dbus/data.rb, line 202 def self.type_code "b" end
validate_raw!(value)
click to toggle source
# File lib/dbus/data.rb, line 214 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
marshall(endianness)
click to toggle source
@param endianness [:little,:big]
# File lib/dbus/data.rb, line 240 def marshall(endianness) int = value ? 1 : 0 [int].pack(UInt32.format[endianness]) end