Class: OpenHAB::Core::Events::Source::Component
- Inherits:
-
Object
- Object
- OpenHAB::Core::Events::Source::Component
- Defined in:
- lib/openhab/core/events/source.rb
Overview
Represents a single component in the event source delegation chain.
Instance Attribute Summary collapse
-
#actor ⇒ String
readonly
The actor (user, device, etc.) that sent the event.
-
#bundle ⇒ String
readonly
The bundle (module, app, etc.) that sent the event.
Class Method Summary collapse
-
.build(bundle, actor = nil) ⇒ Component
Build a Component from the specified bundle and actor.
-
.parse(component) ⇒ Component
Parse a Component from its string representation.
Instance Method Summary collapse
- #!=(other) ⇒ true, false
- #<=>(other) ⇒ Integer?
- #==(other) ⇒ true, false
- #eql?(other) ⇒ Boolean
- #hash ⇒ Integer
- #to_s ⇒ String (also: #to_str)
Instance Attribute Details
#actor ⇒ String (readonly)
The actor (user, device, etc.) that sent the event.
222 223 224 |
# File 'lib/openhab/core/events/source.rb', line 222 def actor @actor end |
#bundle ⇒ String (readonly)
The bundle (module, app, etc.) that sent the event.
218 219 220 |
# File 'lib/openhab/core/events/source.rb', line 218 def bundle @bundle end |
Class Method Details
.build(bundle, actor = nil) ⇒ Component
Build a OpenHAB::Core::Events::Source::Component from the specified bundle and actor.
242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/openhab/core/events/source.rb', line 242 def build(bundle, actor = nil) if AbstractEvent.respond_to?(:build_source) # a bit round-about, but is necessary for argument validation # and escaping # Only present in openHAB 5.1+ begin parse(AbstractEvent.build_source(bundle, actor)) rescue java.lang.IllegalArgumentException => e raise ArgumentError, e.message end else new(bundle, actor) end end |
.parse(component) ⇒ Component
Parse a OpenHAB::Core::Events::Source::Component from its string representation.
231 232 233 |
# File 'lib/openhab/core/events/source.rb', line 231 def parse(component) new(*component.split("$", 2)) end |
Instance Method Details
#!=(other) ⇒ true, false
277 278 279 |
# File 'lib/openhab/core/events/source.rb', line 277 def !=(other) !(self == other) # rubocop:disable Style/InverseMethods end |
#<=>(other) ⇒ Integer?
282 283 284 285 286 287 |
# File 'lib/openhab/core/events/source.rb', line 282 def <=>(other) return 0 if self == other return nil unless other.respond_to?(:to_str) to_s <=> other.to_str end |
#==(other) ⇒ true, false
269 270 271 272 273 274 |
# File 'lib/openhab/core/events/source.rb', line 269 def ==(other) return bundle == other.bundle && actor == other.actor if other.is_a?(Component) return to_s == other.to_str if other.respond_to?(:to_str) false end |
#eql?(other) ⇒ Boolean
289 290 291 |
# File 'lib/openhab/core/events/source.rb', line 289 def eql?(other) other.is_a?(Component) && bundle == other.bundle && actor == other.actor end |
#hash ⇒ Integer
294 295 296 |
# File 'lib/openhab/core/events/source.rb', line 294 def hash [bundle, actor].hash end |
#to_s ⇒ String Also known as: to_str
259 260 261 262 263 264 265 |
# File 'lib/openhab/core/events/source.rb', line 259 def to_s if actor "#{bundle}$#{actor}" else bundle end end |