fixes based on comments for pull request
This commit is contained in:
parent
463ac436a8
commit
b6b7985d6e
4 changed files with 30 additions and 13 deletions
|
@ -86,9 +86,11 @@ module Net::BER::Extensions::Array
|
|||
# [['1.2.840.113556.1.4.805',true]]
|
||||
#
|
||||
def to_ber_control
|
||||
ary = self.collect do |control_sequence|
|
||||
control_sequence.collect{|element| element.to_ber}.to_ber_sequence
|
||||
#if our array does not contain at least one array then wrap it in an array before going forward
|
||||
ary = self[0].kind_of?(Array) ? self : [self]
|
||||
ary = ary.collect do |control_sequence|
|
||||
control_sequence.collect{|element| element.to_ber}.to_ber_sequence.reject_empty_ber_arrays
|
||||
end
|
||||
ary.to_ber_sequence #putting this on a new line to make it more readable.
|
||||
ary.to_ber_sequence.reject_empty_ber_arrays
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,15 +46,19 @@ module Net::BER::Extensions::String
|
|||
def read_ber(syntax = nil)
|
||||
StringIO.new(self).read_ber(syntax)
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# Destructively reads a BER object from the string.
|
||||
# Destructively reads a BER object from the string.
|
||||
def read_ber!(syntax = nil)
|
||||
io = StringIO.new(self)
|
||||
|
||||
result = io.read_ber(syntax)
|
||||
self.slice!(0...io.pos)
|
||||
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
def reject_empty_ber_arrays
|
||||
self.gsub(/0\000/n,'')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue