add data objects
marker class (may change) to be able to check access
This commit is contained in:
@ -5,13 +5,40 @@
|
||||
#
|
||||
|
||||
module Parfait
|
||||
# obviously not a "Word" but a ByteArray , but no such class yet
|
||||
# As our String (Word) on the other hand has no encoding (yet) it is close enough
|
||||
class BinaryCode < Word
|
||||
|
||||
def to_s
|
||||
"BinaryCode #{self.char_length}"
|
||||
class BinaryCode < Data16
|
||||
attr_accessor :next
|
||||
|
||||
def initialize(total_size)
|
||||
super()
|
||||
if total_size > self.data_length
|
||||
@next = BinaryCode.new(total_size - data_length)
|
||||
end
|
||||
#puts "Init with #{total_size} for #{object_id}"
|
||||
end
|
||||
def to_s
|
||||
"BinaryCode #{}"
|
||||
end
|
||||
def data_length
|
||||
14
|
||||
end
|
||||
def char_length
|
||||
4*data_length
|
||||
end
|
||||
def set_char(c , index)
|
||||
if index >= char_length
|
||||
puts "Pass it on #{index} for #{object_id}"
|
||||
return @next.set_char( c , index - char_length)
|
||||
end
|
||||
word_index = (index - 1) / 4 + 2
|
||||
old = get_internal_word( word_index )
|
||||
old = old && c << ((index-1)%4)
|
||||
set_internal_word(word_index , c)
|
||||
end
|
||||
def total_byte_length(start = 0 )
|
||||
start += 4*14
|
||||
return start unless self.next
|
||||
self.next.total_byte_length(start)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user