Class: RASN1::Types::OctetString
- Defined in:
- lib/rasn1/types/octet_string.rb
Overview
ASN.1 Octet String
An OCTET STRINT may contain another primtive object:
os = OctetString.new
int = Integer.new
int.value = 12
os.value = int
os.to_der # => DER string with INTEGER in OCTET STRING
Direct Known Subclasses
BmpString, IA5String, NumericString, PrintableString, UniversalString, Utf8String
Constant Summary collapse
- ID =
OctetString id value
4
Constants inherited from Primitive
Constants inherited from Base
Base::CLASSES, Base::CLASS_MASK, Base::INDEFINITE_LENGTH, Base::MULTI_OCTETS_ID
Instance Attribute Summary
Attributes inherited from Base
#asn1_class, #default, #name, #options
Instance Method Summary collapse
-
#der_to_value(der, ber: false) ⇒ void
Make string value from
derstring. - #inspect(level = 0) ⇒ String
Methods inherited from Base
#==, #can_build?, constrained?, #constructed?, #do_parse, #do_parse_explicit, #do_parse_explicit_with_tracing, #do_parse_with_tracing, encoded_type, #explicit?, #id, #implicit?, #initialize, #initialize_copy, #optional?, parse, #parse!, #primitive?, #specific_initializer, start_tracing, stop_tracing, #tagged?, #to_der, #trace, #type, type, #value, #value=, #value?, #value_size, #void_value
Constructor Details
This class inherits a constructor from RASN1::Types::Base
Instance Method Details
#der_to_value(der, ber: false) ⇒ void
This method returns an undefined value.
Make string value from der string. Force encoding to UTF-8
36 37 38 39 40 41 42 43 |
# File 'lib/rasn1/types/octet_string.rb', line 36 def der_to_value(der, ber: false) klass = self.class if klass.const_defined?(:ENCODING) @value = der.to_s.dup.force_encoding(klass.const_get(:ENCODING)) else super end end |
#inspect(level = 0) ⇒ String
26 27 28 29 |
# File 'lib/rasn1/types/octet_string.rb', line 26 def inspect(level=0) str = common_inspect(level) str << " #{value.inspect}" end |