Class: OpenHAB::Core::Items::GroupItem::Members

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

Instance Method Summary collapse

Methods included from DSL::Items::Ensure::Ensurable

#ensure

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

#groupGroupItem (readonly)

Returns:



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

Parameters:

  • member (Item, String)

    The item to add to the group

Returns:

Raises:

  • (ArgumentError)


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

#inspectString Also known as: to_s

Returns:

  • (String)


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

#nameString

Name of the group

Returns:

  • (String)


116
117
118
# File 'lib/openhab/core/items/group_item.rb', line 116

def name
  group.name
end

#to_aArray

Explicit conversion to Array

Returns:



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