Class: DBus::ObjectPath

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

Overview

A String that validates at initialization time

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s) ⇒ ObjectPath

Returns a new instance of ObjectPath.

Raises:

  • Error if not a valid object path



13
14
15
16
17
18
# File 'lib/dbus/object_path.rb', line 13

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

Class Method Details

.valid?(s) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/dbus/object_path.rb', line 20

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