Class: Xap::Schema::XapBscResponse

Inherits:
XapBscMessage show all
Defined in:
lib/xap/schema/xap_bsc.rb

Overview

Shared functionality between info and event messages.

Direct Known Subclasses

XapBscEvent, XapBscInfo

Instance Attribute Summary collapse

Attributes inherited from XapMessage

#headername, #hop, #msgclass, #src_addr, #target_addr, #uid, #version

Instance Method Summary collapse

Methods inherited from XapBscMessage

#each_block, #inspect, parse

Methods inherited from XapUnsupportedMessage

parse

Methods inherited from XapMessage

parse, register_class, #to_s, #uid_endpoint

Constructor Details

#initialize(src_addr, src_uid, is_input, *args) ⇒ XapBscResponse

Initializes an xAP BSC event or info message with the given source address and UID. If is_input is truthy, this will be an input.state message; if is_input is falsy, this will be an output.state message. Any subsequent arguments are ignored.



320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/xap/schema/xap_bsc.rb', line 320

def initialize src_addr, src_uid, is_input, *args
	if src_addr.is_a?(Hash)
		super src_addr, src_uid, nil, nil, nil
	else
		super self.class.classname, src_addr, src_uid, nil, is_input
		@is_input = !!is_input

		h = {}
		blk = XapBscBlock.new @is_input, nil, h
		@bsc_blocks[0] = blk
		@blocks[blk.blockname] = h
	end
end

Instance Attribute Details

#display_textObject

Gets the message’s DisplayText value, if any.



386
387
388
# File 'lib/xap/schema/xap_bsc.rb', line 386

def display_text
  @display_text
end

#levelObject

Gets the Level value, if any. Returns a two-element array with the numerator and ‘%’ if the message contains a percentage level, or the numerator and denominator if the message contains a ranged level.



376
377
378
# File 'lib/xap/schema/xap_bsc.rb', line 376

def level
  @level
end

#stateObject

Gets the message’s State value. Returns true for ‘ON’, false for ‘OFF’, ‘toggle’ for ‘toggle’, ‘?’ for ‘?’ or any other value, and nil for undefined.



369
370
371
# File 'lib/xap/schema/xap_bsc.rb', line 369

def state
  @state
end

#textObject

Gets the message’s Text value, if any.



381
382
383
# File 'lib/xap/schema/xap_bsc.rb', line 381

def text
  @text
end