Class: Xap::Schema::XapBscCommand
- Inherits:
-
XapBscMessage
- Object
- XapMessage
- XapUnsupportedMessage
- XapBscMessage
- Xap::Schema::XapBscCommand
- Defined in:
- lib/xap/schema/xap_bsc.rb
Instance Attribute Summary
Attributes inherited from XapMessage
#headername, #hop, #msgclass, #src_addr, #target_addr, #uid, #version
Instance Method Summary collapse
-
#get_display_text(index) ⇒ Object
Gets the DisplayText value of the index-th block (0-based).
-
#get_id(index) ⇒ Object
Gets the ID value of the index-th block (0-based).
-
#get_level(index) ⇒ Object
Gets the Level value of the index-th block (0-based).
-
#get_state(index) ⇒ Object
Gets the State value of the index-th block (0-based).
-
#get_text(index) ⇒ Object
Gets the Text value of the index-th block (0-based).
-
#initialize(src_addr, src_uid, target_addr, *args) ⇒ XapBscCommand
constructor
Initializes an xAP BSC command message with the given source address and UID and target address.
-
#set_display_text(index, value) ⇒ Object
Sets the DisplayText value of the index-th block (0-based).
-
#set_id(index, value) ⇒ Object
Sets the ID value of the index-th block (0-based).
-
#set_level(index, value) ⇒ Object
Sets the Level value of the index-th block (0-based).
-
#set_state(index, value) ⇒ Object
Sets the State value of the index-th block (0-based).
-
#set_text(index, value) ⇒ Object
Sets the Text value of the index-th block (0-based).
Methods inherited from XapBscMessage
Methods inherited from XapUnsupportedMessage
Methods inherited from XapMessage
parse, register_class, #to_s, #uid_endpoint
Constructor Details
#initialize(src_addr, src_uid, target_addr, *args) ⇒ XapBscCommand
Initializes an xAP BSC command message with the given source address and UID and target address. Any subsequent arguments are ignored.
194 195 196 197 198 199 200 201 202 |
# File 'lib/xap/schema/xap_bsc.rb', line 194 def initialize src_addr, src_uid, target_addr, *args if src_addr.is_a?(Hash) super src_addr, src_uid, nil, nil, nil else super 'xAPBSC.cmd', src_addr, src_uid, target_addr, false end raise 'All xAP BSC command messages must have a target address.' if @target_addr.nil? check_block 0 end |
Instance Method Details
#get_display_text(index) ⇒ Object
Gets the DisplayText value of the index-th block (0-based). Throws an error if index is out of range.
258 259 260 |
# File 'lib/xap/schema/xap_bsc.rb', line 258 def get_display_text index @bsc_blocks[index].display_text end |
#get_id(index) ⇒ Object
Gets the ID value of the index-th block (0-based). Throws an error if index is out of range.
272 273 274 |
# File 'lib/xap/schema/xap_bsc.rb', line 272 def get_id index @bsc_blocks[index].id end |
#get_level(index) ⇒ Object
Gets the Level value of the index-th block (0-based). Returns an array with the numerator and ‘%’ if the message contains a percentage level, the numerator and denominator if the message contains a ranged level, or just the numerator if the message contains a non-ranged level. Throws an error if index is out of range.
226 227 228 |
# File 'lib/xap/schema/xap_bsc.rb', line 226 def get_level index @bsc_blocks[index].level end |
#get_state(index) ⇒ Object
Gets the State value of the index-th block (0-based). Returns true for ‘ON’, false for ‘OFF’, ‘toggle’ for ‘toggle’, ‘?’ for ‘?’ or any other value, and nil for undefined. Throws an error if index is out of range.
208 209 210 |
# File 'lib/xap/schema/xap_bsc.rb', line 208 def get_state index @bsc_blocks[index].state end |
#get_text(index) ⇒ Object
Gets the Text value of the index-th block (0-based). Throws an error if index is out of range.
244 245 246 |
# File 'lib/xap/schema/xap_bsc.rb', line 244 def get_text index @bsc_blocks[index].text end |
#set_display_text(index, value) ⇒ Object
Sets the DisplayText value of the index-th block (0-based). The block will be created if it is not present. It is up to the caller to avoid creating gaps in the block indexes.
265 266 267 268 |
# File 'lib/xap/schema/xap_bsc.rb', line 265 def set_display_text index, value check_block index @bsc_blocks[index].display_text = value end |
#set_id(index, value) ⇒ Object
Sets the ID value of the index-th block (0-based). The ID given must be either two uppercase hex digits or a single asterisk. The block will be created if it is not present. It is up to the caller to avoid creating gaps in the block indexes.
280 281 282 283 |
# File 'lib/xap/schema/xap_bsc.rb', line 280 def set_id index, value check_block index @bsc_blocks[index].id = value end |
#set_level(index, value) ⇒ Object
Sets the Level value of the index-th block (0-based). The value parameter must be an array containing the numerator and ‘%’ for a percentage level, the numerator and the denominator for a ranged level, or the numerator alone for command messages that will set an endpoint’s level using its native range. The block will be created if it is not present. It is up to the caller to avoid creating gaps in the block indexes.
237 238 239 240 |
# File 'lib/xap/schema/xap_bsc.rb', line 237 def set_level index, value check_block index @bsc_blocks[index].level = value end |
#set_state(index, value) ⇒ Object
Sets the State value of the index-th block (0-based). Pass true for ‘ON’, false for ‘OFF’, ‘toggle’ for ‘toggle’, or any other value for ‘?’. The block will be created if it is not present. It is up to the caller to avoid creating gaps in the block indexes.
216 217 218 219 |
# File 'lib/xap/schema/xap_bsc.rb', line 216 def set_state index, value check_block index @bsc_blocks[index].state = value end |
#set_text(index, value) ⇒ Object
Sets the Text value of the index-th block (0-based). The block will be created if it is not present. It is up to the caller to avoid creating gaps in the block indexes.
251 252 253 254 |
# File 'lib/xap/schema/xap_bsc.rb', line 251 def set_text index, value check_block index @bsc_blocks[index].text = value end |