Class: OpenHAB::Core::Rules::Registry
- Inherits:
- 
      Object
      
        - Object
- OpenHAB::Core::Rules::Registry
 
- Includes:
- LazyArray
- Defined in:
- lib/openhab/core/rules/registry.rb
Overview
Provides access to all openHAB rules, and acts like an array.
Instance Method Summary collapse
- 
  
    
      #[](uid)  ⇒ Rule? 
    
    
      (also: #include?, #key?, #has_key?)
    
  
  
  
  
  
  
  
  
  
    Gets a specific Rule. 
- 
  
    
      #build(preferred_provider = nil) { ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Enter the Rule Builder DSL. 
- 
  
    
      #remove(rule_uid)  ⇒ Rule? 
    
    
  
  
  
  
  
  
  
  
  
    Remove a Rule. 
- 
  
    
      #scenes  ⇒ TaggedArray 
    
    
  
  
  
  
  
  
  
  
  
    Returns all Scenes (rules tagged with "Scene"). 
- 
  
    
      #scripts  ⇒ TaggedArray 
    
    
  
  
  
  
  
  
  
  
  
    Returns all Scripts (rules tagged with "Script"). 
- 
  
    
      #to_a  ⇒ Array<Rule> 
    
    
  
  
  
  
  
  
  
  
  
    Explicit conversion to array. 
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!
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
| 21 22 23 | # File 'lib/openhab/core/rules/registry.rb', line 21 def [](uid) $rules.get(uid) end | 
#build(preferred_provider = nil) { ... } ⇒ Object
Enter the Rule Builder DSL.
| 44 45 46 | # File 'lib/openhab/core/rules/registry.rb', line 44 def build(preferred_provider = nil, &block) DSL::Rules::Builder.new(preferred_provider).instance_eval_with_dummy_items(&block) end | 
#remove(rule_uid) ⇒ Rule?
Remove a Rule.
The rule must be a managed thing (typically created by Ruby or in the UI).
| 64 65 66 67 68 69 70 71 72 73 | # File 'lib/openhab/core/rules/registry.rb', line 64 def remove(rule_uid) rule_uid = rule_uid.uid if rule_uid.is_a?(Rule) return nil unless (provider = Provider.registry.provider_for(rule_uid)) unless provider.is_a?(org.openhab.core.common.registry.ManagedProvider) raise "Cannot remove rule #{rule_uid} from non-managed provider #{provider.inspect}" end provider.remove(rule_uid) end | 
#scenes ⇒ TaggedArray
Returns all Scenes (rules tagged with "Scene")
| 80 81 82 | # File 'lib/openhab/core/rules/registry.rb', line 80 def scenes @scenes ||= TaggedArray.new("Scene") end | 
#scripts ⇒ TaggedArray
Returns all Scripts (rules tagged with "Script")
| 89 90 91 | # File 'lib/openhab/core/rules/registry.rb', line 89 def scripts @scripts ||= TaggedArray.new("Script") end | 
 
          