Class: BinaryBlocker::ListOfEncoder
Instance Method Summary
collapse
attributes, attributes=, #block, clear_registered_klasses, #clone, has_bit_field, has_counted_array, has_fixed_array, has_list_of, has_one, has_one_of, include_klasses, inherited, keys, klasses, klasses=, lookup, lookup=, #method_missing, #orig_clone, register_klass, #to_h, #valid?, #value
Methods inherited from Encoder
#block, #key_value?, #me
Constructor Details
#initialize(classes, *opts) ⇒ ListOfEncoder
Returns a new instance of ListOfEncoder.
900
901
902
903
904
905
906
|
# File 'lib/blocker.rb', line 900
def initialize(classes, *opts)
initialize_options(*opts)
@count = 0
@classes = classes
@value = []
initialize_data(*opts)
end
|
Instance Method Details
#<<(val) ⇒ Object
942
943
944
|
# File 'lib/blocker.rb', line 942
def <<(val)
@value << val
end
|
#[](offset) ⇒ Object
928
929
930
931
|
# File 'lib/blocker.rb', line 928
def [](offset)
raise RangeError.new("Access (#{offset}) out of range (#{@value.size})") unless (0...@value.size) === offset
@value[offset]
end
|
#[]=(offset, val) ⇒ Object
933
934
935
936
|
# File 'lib/blocker.rb', line 933
def []=(offset,val)
raise RangeError.new("Access (#{offset}) out of range (#{@value.size})") unless (0...@value.size) === offset
@value[offset] = val
end
|
#deblock(io) ⇒ Object
916
917
918
919
920
921
922
923
924
925
926
|
# File 'lib/blocker.rb', line 916
def deblock(io)
result = []
with_guarded_io_pos(io) do
oe = OneOfEncoder.new(@classes, @opts)
while oe.deblock(io)
result << oe
oe = OneOfEncoder.new(@classes, @opts)
end
end
@value = result
end
|
#each ⇒ Object
938
939
940
|
# File 'lib/blocker.rb', line 938
def each
@value.each { |v| yield v }
end
|
#internal_block(val) ⇒ Object
912
913
914
|
# File 'lib/blocker.rb', line 912
def internal_block(val)
val.inject("") { |r, o| r + o.block }
end
|
#size ⇒ Object
Also known as:
length
946
947
948
|
# File 'lib/blocker.rb', line 946
def size
@value.size
end
|
#value=(other) ⇒ Object
908
909
910
|
# File 'lib/blocker.rb', line 908
def value=(other)
@value = other.value.clone
end
|