lib/rasn1/model.rb in rasn1-0.3.1 vs lib/rasn1/model.rb in rasn1-0.4.0

- old
+ new

@@ -172,10 +172,11 @@ # Parse a DER/BER encoded string # @param [String] str # @param [Boolean] ber accept BER encoding or not # @return [Model] + # @raise [ASN1Error] error on parsing def parse(str, ber: false) model = new model.parse! str, ber: ber model end @@ -242,10 +243,11 @@ # Parse a DER/BER encoded string, and modify object in-place. # @param [String] str # @param [Boolean] ber accept BER encoding or not # @return [Integer] number of parsed bytes + # @raise [ASN1Error] error on parsing def parse!(str, ber: false) @elements[@root].parse!(str.dup.force_encoding('BINARY'), ber: ber) end # Delegate some methods to root element @@ -254,9 +256,13 @@ if @elements[@root].respond_to? meth @elements[@root].send meth, *args else super end + end + + def inspect(level=0) + ' ' * level + "#{type} #{root.inspect(-level)}" end private def is_composed?(el)