@@ -33,6 +33,8 @@ class ProxyObject
3333 # @return [ApiOptions]
3434 attr_reader :api
3535
36+ OPEN_QUOTE = RUBY_VERSION >= "3.4" ? "'" : "`"
37+
3638 # Creates a new proxy object living on the given _bus_ at destination _dest_
3739 # on the given _path_.
3840 def initialize ( bus , dest , path , api : ApiOptions ::CURRENT )
@@ -58,7 +60,7 @@ def interfaces
5860 def []( intfname )
5961 introspect unless introspected
6062 ifc = @interfaces [ intfname ]
61- raise DBus ::Error , "no such interface ` #{ intfname } ' on object ` #{ @path } '" unless ifc
63+ raise DBus ::Error , "no such interface #{ OPEN_QUOTE } #{ intfname } ' on object #{ OPEN_QUOTE } #{ @path } '" unless ifc
6264
6365 ifc
6466 end
@@ -127,7 +129,8 @@ def has_iface?(name)
127129 # @return [void]
128130 def on_signal ( name , &block )
129131 unless @default_iface && has_iface? ( @default_iface )
130- raise NoMethodError , "undefined signal `#{ name } ' for DBus interface `#{ @default_iface } ' on object `#{ @path } '"
132+ raise NoMethodError , "undefined signal #{ OPEN_QUOTE } #{ name } ' for DBus interface " \
133+ "#{ OPEN_QUOTE } #{ @default_iface } ' on object #{ OPEN_QUOTE } #{ @path } '"
131134 end
132135
133136 @interfaces [ @default_iface ] . on_signal ( name , &block )
@@ -151,18 +154,20 @@ def method_missing(name, *args, &reply_handler)
151154 # - di not specified
152155 # TODO
153156 # - di is specified but not found in introspection data
154- raise NoMethodError , "undefined method `#{ name } ' for DBus interface `#{ @default_iface } ' on object `#{ @path } '"
157+ raise NoMethodError , "undefined method #{ OPEN_QUOTE } #{ name } ' for DBus interface " \
158+ "#{ OPEN_QUOTE } #{ @default_iface } ' on object #{ OPEN_QUOTE } #{ @path } '"
155159 end
156160
157161 begin
158162 @interfaces [ @default_iface ] . method ( name ) . call ( *args , &reply_handler )
159163 rescue NameError => e
160164 # interesting, foo.method("unknown")
161165 # raises NameError, not NoMethodError
162- raise unless e . to_s =~ /undefined method ` #{ name } '/
166+ raise unless e . to_s =~ /undefined method #{ OPEN_QUOTE } #{ name } '/
163167
164168 # BTW e.exception("...") would preserve the class.
165- raise NoMethodError , "undefined method `#{ name } ' for DBus interface `#{ @default_iface } ' on object `#{ @path } '"
169+ raise NoMethodError , "undefined method #{ OPEN_QUOTE } #{ name } ' for DBus interface " \
170+ "#{ OPEN_QUOTE } #{ @default_iface } ' on object #{ OPEN_QUOTE } #{ @path } '"
166171 end
167172 end
168173 # rubocop:enable Lint/MissingSuper
0 commit comments