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 207 def self.alignment 208 4 209 end
format()
click to toggle source
# File lib/dbus/data.rb 211 def self.format 212 FORMAT 213 end
from_raw(value, mode:)
click to toggle source
# File lib/dbus/data.rb 221 def self.from_raw(value, mode:) 222 validate_raw!(value) 223 224 value = value == 1 225 return value if mode == :plain 226 227 new(value) 228 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 235 def initialize(value) 236 value = value.value if value.is_a?(self.class) 237 super(value ? true : false) 238 end
type_code()
click to toggle source
# File lib/dbus/data.rb 203 def self.type_code 204 "b" 205 end
validate_raw!(value)
click to toggle source
# File lib/dbus/data.rb 215 def self.validate_raw!(value) 216 return if [0, 1].member?(value) 217 218 raise InvalidPacketException, "BOOLEAN must be 0 or 1, found #{value}" 219 end
Public Instance Methods
marshall(endianness)
click to toggle source
@param endianness [:little,:big]
# File lib/dbus/data.rb 241 def marshall(endianness) 242 int = value ? 1 : 0 243 [int].pack(UInt32.format[endianness]) 244 end