Class: Xap::Schema::XapBscMessage
- Inherits:
-
XapUnsupportedMessage
- Object
- XapMessage
- XapUnsupportedMessage
- Xap::Schema::XapBscMessage
- Defined in:
- lib/xap/schema/xap_bsc.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from XapMessage
#headername, #hop, #msgclass, #src_addr, #target_addr, #uid, #version
Class Method Summary collapse
Instance Method Summary collapse
-
#each_block(&block) ⇒ Object
Yields each XapBscBlock in sequence.
-
#initialize(msgclass, src_addr, src_uid, target_addr, is_input) ⇒ XapBscMessage
constructor
A new instance of XapBscMessage.
-
#inspect ⇒ Object
Returns a human-readable string description of this message.
Methods inherited from XapMessage
register_class, #to_s, #uid_endpoint
Constructor Details
#initialize(msgclass, src_addr, src_uid, target_addr, is_input) ⇒ XapBscMessage
Returns a new instance of XapBscMessage.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/xap/schema/xap_bsc.rb', line 149 def initialize msgclass, src_addr, src_uid, target_addr, is_input super msgclass, src_addr, src_uid, target_addr if msgclass.is_a?(Hash) raise 'xAP BSC messages must have at least one block' if @blocks.length == 0 @is_input = @blocks.keys[0].downcase.start_with? 'input' else @is_input = is_input end @bsc_blocks = [] idx = 0 @blocks.each do |k, v| kdown = k.downcase if kdown.start_with?('input') || kdown.start_with?('output') @bsc_blocks << XapBscBlock.new(@is_input, idx, v) end idx += 1 if idx end end |
Class Method Details
.parse(hash) ⇒ Object
145 146 147 |
# File 'lib/xap/schema/xap_bsc.rb', line 145 def self.parse hash self.new hash, nil, nil, nil, nil end |
Instance Method Details
#each_block(&block) ⇒ Object
Yields each XapBscBlock in sequence.
182 183 184 185 186 |
# File 'lib/xap/schema/xap_bsc.rb', line 182 def each_block &block @bsc_blocks.each do |b| yield b end end |
#inspect ⇒ Object
Returns a human-readable string description of this message.
171 172 173 174 175 176 177 178 179 |
# File 'lib/xap/schema/xap_bsc.rb', line 171 def inspect s = "#{self.class.name}: #{@bsc_blocks.length} blocks recognized, #{@blocks.length} total\n" s << "Blocks: \n" @bsc_blocks.each do |blk| s << "\t#{blk.inspect}\n" end s << "Regenerated message:\n\t" s << super.lines.to_a.join("\t") end |