Class: OpenHAB::RSpec::Mocks::ThingHandler
- Inherits:
-
Object
- Object
- OpenHAB::RSpec::Mocks::ThingHandler
- Defined in:
- lib/openhab/rspec/mocks/thing_handler.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#thing ⇒ Object
readonly
Returns the value of attribute thing.
Instance Method Summary collapse
- #channel_linked(_channel_uid) ⇒ Object
- #channel_unlinked(_channel_uid) ⇒ Object
- #child_handler_disposed(child_handler, child_thing) ⇒ Object
- #child_handler_initialized(child_handler, child_thing) ⇒ Object
- #dispose ⇒ Object
- #handle_command(channel_uid, command) ⇒ Object
-
#initialize(thing = nil) ⇒ ThingHandler
constructor
A new instance of ThingHandler.
- #send_time_series(channel_uid, time_series) ⇒ Object
- #set_callback(callback) ⇒ Object
- #thing_updated(thing) ⇒ Object
Constructor Details
#initialize(thing = nil) ⇒ ThingHandler
Returns a new instance of ThingHandler.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 15 def initialize(thing = nil) # have to handle the interface method if thing.nil? status_info = org.openhab.core.thing.binding.builder.ThingStatusInfoBuilder .create(org.openhab.core.thing.ThingStatus::ONLINE).build @callback.status_updated(self.thing, status_info) return end # ruby initializer here @thing = thing end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
13 14 15 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 13 def callback @callback end |
#thing ⇒ Object (readonly)
Returns the value of attribute thing.
13 14 15 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 13 def thing @thing end |
Instance Method Details
#channel_linked(_channel_uid) ⇒ Object
51 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 51 def channel_linked(_channel_uid); end |
#channel_unlinked(_channel_uid) ⇒ Object
52 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 52 def channel_unlinked(_channel_uid); end |
#child_handler_disposed(child_handler, child_thing) ⇒ Object
49 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 49 def child_handler_disposed(child_handler, child_thing); end |
#child_handler_initialized(child_handler, child_thing) ⇒ Object
48 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 48 def child_handler_initialized(child_handler, child_thing); end |
#dispose ⇒ Object
54 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 54 def dispose; end |
#handle_command(channel_uid, command) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 32 def handle_command(channel_uid, command) channel = thing.get_channel(channel_uid) return unless channel return if channel.auto_update_policy == org.openhab.core.thing.type.AutoUpdatePolicy::VETO callback&.state_updated(channel_uid, command) if command.is_a?(Core::Types::State) end |
#send_time_series(channel_uid, time_series) ⇒ Object
40 41 42 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 40 def send_time_series(channel_uid, time_series) @callback&.send_time_series(channel_uid, time_series) end |
#set_callback(callback) ⇒ Object
44 45 46 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 44 def set_callback(callback) @callback = callback end |
#thing_updated(thing) ⇒ Object
28 29 30 |
# File 'lib/openhab/rspec/mocks/thing_handler.rb', line 28 def thing_updated(thing) @thing = thing end |