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.
221 222 223 |
# File 'lib/openhab/core/events/source.rb', line 221 def actor @actor end |
#bundle ⇒ String (readonly)
The bundle (module, app, etc.) that sent the event.
217 218 219 |
# File 'lib/openhab/core/events/source.rb', line 217 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.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/openhab/core/events/source.rb', line 241 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.
230 231 232 |
# File 'lib/openhab/core/events/source.rb', line 230 def parse(component) new(*component.split("$", 2)) end |
Instance Method Details
#!=(other) ⇒ true, false
276 277 278 |
# File 'lib/openhab/core/events/source.rb', line 276 def !=(other) !(self == other) # rubocop:disable Style/InverseMethods end |
#<=>(other) ⇒ Integer?
281 282 283 284 285 286 |
# File 'lib/openhab/core/events/source.rb', line 281 def <=>(other) return 0 if self == other return nil unless other.respond_to?(:to_str) to_s <=> other.to_str end |
#==(other) ⇒ true, false
268 269 270 271 272 273 |
# File 'lib/openhab/core/events/source.rb', line 268 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
288 289 290 |
# File 'lib/openhab/core/events/source.rb', line 288 def eql?(other) other.is_a?(Component) && bundle == other.bundle && actor == other.actor end |
#hash ⇒ Integer
293 294 295 |
# File 'lib/openhab/core/events/source.rb', line 293 def hash [bundle, actor].hash end |
#to_s ⇒ String Also known as: to_str
258 259 260 261 262 263 264 |
# File 'lib/openhab/core/events/source.rb', line 258 def to_s if actor "#{bundle}$#{actor}" else bundle end end |