Class: OpenHAB::Core::Things::Thing::ChannelsArray

Inherits:
Array
  • Object
show all
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

Methods inherited from Array

wrap

Instance Method Details

#[](index) ⇒ Object

Allows indexing by both integer as an array or channel id acting like a hash.

Parameters:

  • index (Integer, String)

    Numeric index or string channel id to search for.



46
47
48
49
50
51
52
53
# File 'lib/openhab/core/things/thing.rb', line 46

def [](index)
  if index.respond_to?(:to_str)
    key = index.to_str
    return find { |channel| channel.uid.id == key }
  end

  super
end