Class: DBus::BusName

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

Overview

D-Bus: a name for a connection, like “:1.3” or “org.example.ManagerManager”. Implemented as a String that validates at initialization time.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ BusName

Returns a new instance of BusName.

Raises:

  • Error if not a valid bus name



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

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

  super
end

Class Method Details

.valid?(name) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/dbus/bus_name.rb', line 25

def self.valid?(name)
  name.size <= 255 &&
    (name =~ /\A:[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)+\z/ ||
     name =~ /\A[A-Za-z_-][A-Za-z0-9_-]*(\.[A-Za-z_-][A-Za-z0-9_-]*)+\z/)
end