Sha256: 0975766a6d30679493a8e6b9006999168f3e575f941bebb497ee827d84664225

Contents?: true

Size: 902 Bytes

Versions: 17

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

# This file is part of the ruby-dbus project
# Copyright (C) 2019 Martin Vidner
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License, version 2.1 as published by the Free Software Foundation.
# See the file "COPYING" for the exact licensing terms.

module DBus
  # A {::String} that validates at initialization time.
  # See also {DBus::Data::ObjectPath}
  # @see https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path
  class ObjectPath < String
    # @raise Error if not a valid object path
    def initialize(str)
      unless self.class.valid?(str)
        raise DBus::Error, "Invalid object path #{str.inspect}"
      end

      super
    end

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ruby-dbus-0.24.0 lib/dbus/object_path.rb
ruby-dbus-0.23.1 lib/dbus/object_path.rb
ruby-dbus-0.23.0.beta2 lib/dbus/object_path.rb
ruby-dbus-0.23.0.beta1 lib/dbus/object_path.rb
ruby-dbus-0.22.1 lib/dbus/object_path.rb
ruby-dbus-0.22.0 lib/dbus/object_path.rb
ruby-dbus-0.21.0 lib/dbus/object_path.rb
ruby-dbus-0.20.0 lib/dbus/object_path.rb
ruby-dbus-0.19.0 lib/dbus/object_path.rb
ruby-dbus-0.18.1 lib/dbus/object_path.rb
ruby-dbus-0.18.0.beta8 lib/dbus/object_path.rb
ruby-dbus-0.18.0.beta7 lib/dbus/object_path.rb
ruby-dbus-0.18.0.beta6 lib/dbus/object_path.rb
ruby-dbus-0.18.0.beta5 lib/dbus/object_path.rb
ruby-dbus-0.18.0.beta4 lib/dbus/object_path.rb
ruby-dbus-0.18.0.beta3 lib/dbus/object_path.rb
ruby-dbus-0.18.0.beta2 lib/dbus/object_path.rb