Class: DBus::Data::Base
- Inherits:
-
Object
- Object
- DBus::Data::Base
- Defined in:
- lib/dbus/data.rb
Overview
The base class for explicitly typed values.
A value is either Basic or a Container. Basic values are either Fixed-size or StringLike.
Instance Attribute Summary collapse
-
#value ⇒ ::Object
readonly
A valid value, plain-Ruby typed.
Class Method Summary collapse
- .assert_type_matches_class(type) ⇒ Object
- .basic? ⇒ Boolean
- .fixed? ⇒ Boolean
-
.from_typed(value, type: ) ⇒ Base
private
Use make_typed instead.
-
.type_code ⇒ String
A single-character string, for example “a” for arrays.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#eql?(other) ⇒ Boolean
Hash key equality See ruby-doc.org/core-3.0.0/Object.html#method-i-eql-3F Stricter than #== (RSpec: eq), 1==1.0 but 1.eql(1.0)->false.
-
#initialize(value) ⇒ Base
constructor
Child classes must validate value.
-
#type ⇒ Type
abstract
Note that for Variants type==“v”, for the specific see Variant#member_type.
Constructor Details
#initialize(value) ⇒ Base
Child classes must validate value.
84 85 86 |
# File 'lib/dbus/data.rb', line 84 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ ::Object (readonly)
Returns a valid value, plain-Ruby typed.
63 64 65 |
# File 'lib/dbus/data.rb', line 63 def value @value end |
Class Method Details
.assert_type_matches_class(type) ⇒ Object
107 108 109 110 |
# File 'lib/dbus/data.rb', line 107 def self.assert_type_matches_class(type) raise ArgumentError, "Expecting #{type_code.inspect} for class #{self}, got #{type.sigtype.inspect}" \ unless type.sigtype == type_code end |
.from_typed(value, type: ) ⇒ Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use DBus::Data.make_typed instead. Construct an instance of the specific subclass, with a type further specified in the type argument.
|
# File 'lib/dbus/data.rb', line 74
|
.type_code ⇒ String
Returns a single-character string, for example “a” for arrays.
|
# File 'lib/dbus/data.rb', line 65
|
Instance Method Details
#==(other) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/dbus/data.rb', line 88 def ==(other) @value == if other.is_a?(Base) other.value else other end end |
#eql?(other) ⇒ Boolean
Hash key equality See ruby-doc.org/core-3.0.0/Object.html#method-i-eql-3F Stricter than #== (RSpec: eq), 1==1.0 but 1.eql(1.0)->false
99 100 101 102 103 104 |
# File 'lib/dbus/data.rb', line 99 def eql?(other) return false unless other.class == self.class other.value.eql?(@value) # TODO: this should work, now check derived classes, exact_value end |
#type ⇒ Type
Note that for Variants type==“v”, for the specific see Variant#member_type
|
# File 'lib/dbus/data.rb', line 68
|