Class: OpenHAB::Core::Things::Thing::ChannelsArray
- Defined in:
- lib/openhab/core/things/thing.rb
Overview
Array wrapper class to allow searching a list of channels by channel id
Instance Method Summary collapse
-
#[](index) ⇒ Channel?
Allows indexing by both integer as an array or channel id acting like a hash.
-
#initialize(thing, array) ⇒ ChannelsArray
constructor
A new instance of ChannelsArray.
Methods inherited from Array
Constructor Details
#initialize(thing, array) ⇒ ChannelsArray
Returns a new instance of ChannelsArray.
78 79 80 81 |
# File 'lib/openhab/core/things/thing.rb', line 78 def initialize(thing, array) super(array) @thing = thing end |
Instance Method Details
#[](index) ⇒ Channel?
Allows indexing by both integer as an array or channel id acting like a hash.
87 88 89 90 91 92 |
# File 'lib/openhab/core/things/thing.rb', line 87 def [](index) return @thing.get_channel(index) if index.is_a?(ChannelUID) return @thing.get_channel(index.to_str) if index.respond_to?(:to_str) super end |