Class: OpenHAB::Core::Rules::TaggedArray

Inherits:
Object
  • Object
show all
Includes:
LazyArray
Defined in:
lib/openhab/core/rules/tagged_array.rb

Overview

Provides access to a set of openHAB rules, and acts like an array.

Instance Method Summary collapse

Methods included from LazyArray

#each, #method_missing, #to_ary

Methods included from Enumerable

#all_groups, #all_members, #command, #command!, #decrease, #down, #equipments, #fast_forward, #groups, #increase, #locations, #member_of, #members, #move, #next, #not_member_of, #not_tagged, #off, #on, #pause, #play, #points, #previous, #refresh, #rewind, #stop, #tagged, #toggle, #up, #update, #update!

Constructor Details

#initialize(tag) ⇒ TaggedArray

Returns a new instance of TaggedArray.



14
15
16
# File 'lib/openhab/core/rules/tagged_array.rb', line 14

def initialize(tag)
  @tag = tag
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OpenHAB::Core::LazyArray

Instance Method Details

#[](uid) ⇒ Rule? Also known as: include?, key?, has_key?

Gets a specific Rule

Parameters:

  • uid (String)

    Rule UID

Returns:



24
25
26
27
# File 'lib/openhab/core/rules/tagged_array.rb', line 24

def [](uid)
  rule = $rules.get(uid)
  rule.tagged?(@tag) ? rule : nil
end

#to_aArray<Rule>

Explicit conversion to array

Returns:



38
39
40
# File 'lib/openhab/core/rules/tagged_array.rb', line 38

def to_a
  $rules.all.to_a.tagged(@tag)
end