Class: DBus::ObjectPath

Inherits:
String
  • Object
show all
Defined in:
lib/dbus/object_path.rb

Overview

A String that validates at initialization time. See also Data::ObjectPath

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ ObjectPath

Returns a new instance of ObjectPath.

Raises:

  • Error if not a valid object path



17
18
19
20
21
22
23
# File 'lib/dbus/object_path.rb', line 17

def initialize(str)
  unless self.class.valid?(str)
    raise DBus::Error, "Invalid object path #{str.inspect}"
  end

  super
end

Class Method Details

.valid?(str) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/dbus/object_path.rb', line 25

def self.valid?(str)
  str == "/" || str =~ %r{\A(/[A-Za-z0-9_]+)+\z}
end