Class: DBus::Data::String
- Inherits:
-
StringLike
- Object
- Base
- Basic
- StringLike
- DBus::Data::String
- Defined in:
- lib/dbus/data.rb
Overview
UTF-8 encoded string.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .alignment ⇒ Object
- .from_raw(value, mode:) ⇒ Object
- .size_class ⇒ Object
- .type_code ⇒ Object
- .validate_raw!(value) ⇒ Object
Methods inherited from StringLike
Methods inherited from Basic
basic?, from_typed, type, #type
Methods inherited from Base
#==, assert_type_matches_class, basic?, #eql?, fixed?, from_typed, #initialize, #type
Constructor Details
This class inherits a constructor from DBus::Data::StringLike
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 |
.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 |