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.



69
70
71
72
73
74
75
76
# File 'lib/openhab/core/things/thing.rb', line 69

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

  super
end