Class: OpenHAB::DSL::Things::ChannelBuilder
- Inherits:
-
Object
- Object
- OpenHAB::DSL::Things::ChannelBuilder
- Defined in:
- lib/openhab/dsl/things/builder.rb
Overview
The ChannelBuilder DSL allows you to customize a channel
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#label ⇒ Object
Returns the value of attribute label.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
-
#initialize(uid, type, label = nil, thing:, group: nil, config: {}) ⇒ ChannelBuilder
constructor
Constructor for ChannelBuilder.
Constructor Details
#initialize(uid, type, label = nil, thing:, group: nil, config: {}) ⇒ ChannelBuilder
Constructor for ChannelBuilder
This class is instantiated by the #channel method inside a Builder#thing block.
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/openhab/dsl/things/builder.rb', line 255 def initialize(uid, type, label = nil, thing:, group: nil, config: {}) @thing = thing uid = uid.to_s uid_segments = uid.split(org.openhab.core.common.AbstractUID::SEPARATOR) group_segments = uid_segments.last.split(org.openhab.core.thing.ChannelUID::CHANNEL_GROUP_SEPARATOR) if group if group_segments.length == 2 group_segments[0] = group else group_segments.unshift(group) end uid_segments[-1] = group_segments.join(org.openhab.core.thing.ChannelUID::CHANNEL_GROUP_SEPARATOR) end @uid = org.openhab.core.thing.ChannelUID.new(thing.uid, uid_segments.last) unless type.is_a?(org.openhab.core.thing.type.ChannelTypeUID) type = org.openhab.core.thing.type.ChannelTypeUID.new(thing.uid.binding_id, type) end @type = type @label = label @config = config.transform_keys(&:to_s) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
240 241 242 |
# File 'lib/openhab/dsl/things/builder.rb', line 240 def config @config end |
#label ⇒ Object
Returns the value of attribute label.
239 240 241 |
# File 'lib/openhab/dsl/things/builder.rb', line 239 def label @label end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
240 241 242 |
# File 'lib/openhab/dsl/things/builder.rb', line 240 def type @type end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
240 241 242 |
# File 'lib/openhab/dsl/things/builder.rb', line 240 def uid @uid end |