Class: DBus::Data::String
Overview
Instance Attribute Summary
Attributes inherited from Base
#value
Class Method Summary
collapse
Methods inherited from StringLike
fixed?, #initialize
Methods inherited from Basic
basic?, from_typed, type, #type
Methods inherited from Base
#==, assert_type_matches_class, basic?, #eql?, fixed?, from_typed, #initialize, #type
Class Method Details
.alignment ⇒ Object
421
422
423
|
# File 'lib/dbus/data.rb', line 421
def self.alignment
4
end
|
.from_raw(value, mode:) ⇒ Object
437
438
439
440
441
442
443
444
445
|
# File 'lib/dbus/data.rb', line 437
def self.from_raw(value, mode:)
value.force_encoding(Encoding::UTF_8)
if mode == :plain
validate_raw!(value)
return value
end
new(value)
end
|
.size_class ⇒ Object
425
426
427
|
# File 'lib/dbus/data.rb', line 425
def self.size_class
UInt32
end
|
.type_code ⇒ Object
417
418
419
|
# File 'lib/dbus/data.rb', line 417
def self.type_code
"s"
end
|
.validate_raw!(value) ⇒ Object
429
430
431
432
433
434
435
|
# File 'lib/dbus/data.rb', line 429
def self.validate_raw!(value)
value.each_codepoint do |cp|
raise InvalidPacketException, "Invalid string, contains NUL" if cp.zero?
end
rescue ArgumentError
raise InvalidPacketException, "Invalid string, not in UTF-8"
end
|