Class: OpenHAB::Core::Items::GroupItem::Members
- Inherits:
-
Object
- Object
- OpenHAB::Core::Items::GroupItem::Members
- Includes:
- LazyArray, DSL::Items::Ensure::Ensurable
- Defined in:
- lib/openhab/core/items/group_item.rb
Overview
Class for indicating to triggers that a group trigger should be used
Instance Attribute Summary collapse
- #group ⇒ GroupItem readonly
Instance Method Summary collapse
-
#add(member) ⇒ Members
(also: #<<)
Adds a member to the group.
- #inspect ⇒ String (also: #to_s)
-
#name ⇒ String
Name of the group.
-
#to_a ⇒ Array
Explicit conversion to Array.
Methods included from DSL::Items::Ensure::Ensurable
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 Attribute Details
#group ⇒ GroupItem (readonly)
79 80 81 |
# File 'lib/openhab/core/items/group_item.rb', line 79 def group @group end |
Instance Method Details
#add(member) ⇒ Members Also known as: <<
Adds a member to the group
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/openhab/core/items/group_item.rb', line 92 def add(member) if member.is_a?(String) member = items[member] raise ArgumentError, "Item not found: #{member}" if member.nil? end member = member.__getobj__ if member.is_a?(Proxy) raise ArgumentError, "Member must be an Item" unless member.is_a?(Item) group.add_member(member) self end |
#inspect ⇒ String Also known as: to_s
121 122 123 124 125 |
# File 'lib/openhab/core/items/group_item.rb', line 121 def inspect r = "#<OpenHAB::Core::Items::GroupItems::Members #{name}" r += " #{map(&:name).inspect}>" unless @group.__getobj__.nil? "#{r}>" end |
#name ⇒ String
Name of the group
116 117 118 |
# File 'lib/openhab/core/items/group_item.rb', line 116 def name group.name end |
#to_a ⇒ Array
Explicit conversion to Array
109 110 111 |
# File 'lib/openhab/core/items/group_item.rb', line 109 def to_a group.get_members.map { |i| Proxy.new(i) } end |