class RQRCodeCore::QRRSBlock
def self.get_rs_block_table(version, error_correct_level)
def self.get_rs_block_table(version, error_correct_level) case error_correct_level when QRERRORCORRECTLEVEL[:l] QRRSBlock::RS_BLOCK_TABLE[(version - 1) * 4 + 0] when QRERRORCORRECTLEVEL[:m] QRRSBlock::RS_BLOCK_TABLE[(version - 1) * 4 + 1] when QRERRORCORRECTLEVEL[:q] QRRSBlock::RS_BLOCK_TABLE[(version - 1) * 4 + 2] when QRERRORCORRECTLEVEL[:h] QRRSBlock::RS_BLOCK_TABLE[(version - 1) * 4 + 3] end end
def self.get_rs_blocks(version, error_correct_level)
def self.get_rs_blocks(version, error_correct_level) rs_block = QRRSBlock.get_rs_block_table(version, error_correct_level) if rs_block.nil? raise QRCodeRunTimeError, "bad rsblock @ version: #{version}/error_correct_level:#{error_correct_level}" end length = rs_block.size / 3 list = [] (0...length).each do |i| count = rs_block[i * 3 + 0] total_count = rs_block[i * 3 + 1] data_count = rs_block[i * 3 + 2] (0...count).each do |j| list << QRRSBlock.new(total_count, data_count) end end list end
def initialize(total_count, data_count)
def initialize(total_count, data_count) @total_count = total_count @data_count = data_count end