Class: OpenHAB::DSL::Items::GroupItemBuilder

Inherits:
ItemBuilder
  • Object
show all
Includes:
Builder
Defined in:
lib/openhab/dsl/items/builder.rb

Overview

Allows customizing a group. You can also call any method from Builder, and those items will automatically be a member of this group.

Instance Attribute Summary collapse

Attributes inherited from ItemBuilder

#autoupdate, #command_options, #dimension, #format, #icon, #label, #metadata, #name, #range, #read_only, #state, #state_options, #step, #type

Instance Method Summary collapse

Methods included from Builder

#call_item, #color_item, #contact_item, #date_time_item, #dimmer_item, #group_item, #image_item, #location_item, #number_item, #player_item, #rollershutter_item, #string_item, #switch_item

Methods included from Core::EntityLookup

#items, #method_missing, #things

Methods inherited from ItemBuilder

#alexa, #channel, #expire, #ga, #group, #homekit, #inspect, #tag, #to_s

Constructor Details

#initialize(*args, type: nil, function: nil, thing: nil, **kwargs) ⇒ GroupItemBuilder

Returns a new instance of GroupItemBuilder.

Parameters:

Raises:

  • (ArgumentError)


820
821
822
823
824
825
826
827
# File 'lib/openhab/dsl/items/builder.rb', line 820

def initialize(*args, type: nil, function: nil, thing: nil, **kwargs)
  raise ArgumentError, "invalid function #{function}" if function && !function.match?(FUNCTION_REGEX)

  super(type, *args, **kwargs)
  @function = function
  @members = []
  @thing = thing
end

Dynamic Method Handling

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

Instance Attribute Details

#functionString?

The combiner function for this group

Returns:

  • (String, nil)


801
802
803
# File 'lib/openhab/dsl/items/builder.rb', line 801

def function
  @function
end

#label_baseString?

A prefix to be added to the label of any member items

Returns:

  • (String, nil)


810
811
812
# File 'lib/openhab/dsl/items/builder.rb', line 810

def label_base
  @label_base
end

#membersArray<ItemBuilder> (readonly)

Members to be created in this group

Returns:



813
814
815
# File 'lib/openhab/dsl/items/builder.rb', line 813

def members
  @members
end

#name_baseString?

A prefix to be added to the name of any member items

Returns:

  • (String, nil)


807
808
809
# File 'lib/openhab/dsl/items/builder.rb', line 807

def name_base
  @name_base
end

#thingCore::Things::ThingUID, ...

A thing to be used as the base for the channel of any member items

Returns:



804
805
806
# File 'lib/openhab/dsl/items/builder.rb', line 804

def thing
  @thing
end

#unitString? (readonly)

Unit (for number items only)

Due to ItemBuilder#format inference, setting the unit is cross-compatible with openHAB 3.4 and 4.0.

Returns:

  • (String, nil)


782
783
784
# File 'lib/openhab/dsl/items/builder.rb', line 782

def unit
  @unit
end